Skip to content

Commit

Permalink
feat: support custom workspaceRoot for angular CT (#26030)
Browse files Browse the repository at this point in the history
* fix: support custom workspaceRoot for angular CT

* test(system-tests): wip nx system tests

* test: remove system-tests until we can test nx

---------

Co-authored-by: Jordan <[email protected]>
  • Loading branch information
barbados-clemens and jordanpowell88 authored Mar 15, 2023
1 parent cfd4088 commit ea8173f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions npm/webpack-dev-server/src/helpers/angularHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ export function getAngularBuildOptions (buildOptions: BuildOptions, tsConfig: st
export async function generateTsConfig (devServerConfig: AngularWebpackDevServerConfig, buildOptions: BuildOptions): Promise<string> {
const { cypressConfig } = devServerConfig
const { projectRoot } = cypressConfig
const { workspaceRoot = projectRoot } = buildOptions

const specPattern = Array.isArray(cypressConfig.specPattern) ? cypressConfig.specPattern : [cypressConfig.specPattern]

const getProjectFilePath = (...fileParts: string[]): string => toPosix(path.join(projectRoot, ...fileParts))
const getProjectFilePath = (...fileParts: string[]): string => toPosix(path.join(...fileParts))

const includePaths = [...specPattern.map((pattern) => getProjectFilePath(pattern))]
const includePaths = [...specPattern.map((pattern) => getProjectFilePath(projectRoot, pattern))]

if (cypressConfig.supportFile) {
includePaths.push(toPosix(cypressConfig.supportFile))
Expand All @@ -131,17 +132,17 @@ export async function generateTsConfig (devServerConfig: AngularWebpackDevServer
? buildOptions.polyfills.filter((p: string) => devServerConfig.options?.projectConfig.sourceRoot && p.startsWith(devServerConfig.options?.projectConfig.sourceRoot))
: [buildOptions.polyfills]

includePaths.push(...polyfills.map((p: string) => getProjectFilePath(p)))
includePaths.push(...polyfills.map((p: string) => getProjectFilePath(workspaceRoot, p)))
}

const cypressTypes = getProjectFilePath('node_modules', 'cypress', 'types', 'index.d.ts')
const cypressTypes = getProjectFilePath(workspaceRoot, 'node_modules', 'cypress', 'types', 'index.d.ts')

includePaths.push(cypressTypes)

const tsConfigContent = JSON.stringify({
extends: getProjectFilePath(buildOptions.tsConfig ?? 'tsconfig.json'),
extends: getProjectFilePath(projectRoot, buildOptions.tsConfig ?? 'tsconfig.json'),
compilerOptions: {
outDir: getProjectFilePath('out-tsc/cy'),
outDir: getProjectFilePath(projectRoot, 'out-tsc/cy'),
allowSyntheticDefaultImports: true,
skipLibCheck: true,
},
Expand Down Expand Up @@ -253,7 +254,7 @@ async function getAngularCliWebpackConfig (devServerConfig: AngularWebpackDevSer

const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig)

const context = createFakeContext(projectRoot, projectConfig, logging)
const context = createFakeContext(projectConfig.buildOptions.workspaceRoot || projectRoot, projectConfig, logging)

const { config } = await generateBrowserWebpackConfigFromContext(
buildOptions,
Expand All @@ -275,10 +276,10 @@ async function getAngularCliWebpackConfig (devServerConfig: AngularWebpackDevSer
return
}

const root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot)
const root = projectConfig.buildOptions.workspaceRoot || path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot)

debug('Adding root %s to resolve-url-loader options', root)
loader.options.root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot)
loader.options.root = root
})
})
})
Expand Down

5 comments on commit ea8173f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea8173f Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.8.2/linux-arm64/develop-ea8173f6d9bc41657987349abcff44f7d14d1777/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea8173f Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.8.2/linux-x64/develop-ea8173f6d9bc41657987349abcff44f7d14d1777/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea8173f Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.8.2/darwin-x64/develop-ea8173f6d9bc41657987349abcff44f7d14d1777/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea8173f Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.8.2/darwin-arm64/develop-ea8173f6d9bc41657987349abcff44f7d14d1777/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea8173f Mar 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.8.2/win32-x64/develop-ea8173f6d9bc41657987349abcff44f7d14d1777/cypress.tgz

Please sign in to comment.