diff --git a/npm/webpack-dev-server/src/helpers/angularHandler.ts b/npm/webpack-dev-server/src/helpers/angularHandler.ts index 0ef004aba0ca..0daa2d355d7f 100644 --- a/npm/webpack-dev-server/src/helpers/angularHandler.ts +++ b/npm/webpack-dev-server/src/helpers/angularHandler.ts @@ -133,7 +133,7 @@ export async function generateTsConfig (devServerConfig: AngularWebpackDevServer includePaths.push(cypressTypes) const tsConfigContent = JSON.stringify({ - extends: getProjectFilePath('tsconfig.json'), + extends: getProjectFilePath(buildOptions.tsConfig ?? 'tsconfig.json'), compilerOptions: { outDir: getProjectFilePath('out-tsc/cy'), allowSyntheticDefaultImports: true, diff --git a/npm/webpack-dev-server/test/handlers/angularHandler.spec.ts b/npm/webpack-dev-server/test/handlers/angularHandler.spec.ts index 02ef0a9fef58..6aac320eb345 100644 --- a/npm/webpack-dev-server/test/handlers/angularHandler.spec.ts +++ b/npm/webpack-dev-server/test/handlers/angularHandler.spec.ts @@ -195,7 +195,8 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC let tsConfig = JSON.parse(await fs.readFile(tsConfigPath, 'utf8')) expect(tsConfig).to.deep.eq({ - extends: toPosix(path.join(projectRoot, 'tsconfig.json')), + // verifies the default `tsconfig.app.json` is extended + extends: toPosix(path.join(projectRoot, 'tsconfig.app.json')), compilerOptions: { outDir: toPosix(path.join(projectRoot, 'out-tsc/cy')), allowSyntheticDefaultImports: true, @@ -211,6 +212,7 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC const modifiedBuildOptions = cloneDeep(buildOptions) delete modifiedBuildOptions.polyfills + modifiedBuildOptions.tsConfig = 'tsconfig.cy.json' const modifiedDevServerConfig = cloneDeep(devServerConfig) const supportFile = path.join(projectRoot, 'cypress', 'support', 'component.ts') @@ -220,9 +222,18 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC tsConfigPath = await generateTsConfig(modifiedDevServerConfig, modifiedBuildOptions) tsConfig = JSON.parse(await fs.readFile(tsConfigPath, 'utf8')) - expect(tsConfig.include).to.deep.equal([ - toPosix(path.join(projectRoot, 'src/**/*.cy.ts')), - toPosix(supportFile), - toPosix(path.join(projectRoot, 'node_modules/cypress/types/index.d.ts')), - ]) + expect(tsConfig).to.deep.eq({ + // verifies the custom `tsconfig.cy.json` is extended + extends: toPosix(path.join(projectRoot, 'tsconfig.cy.json')), + compilerOptions: { + outDir: toPosix(path.join(projectRoot, 'out-tsc/cy')), + allowSyntheticDefaultImports: true, + skipLibCheck: true, + }, + include: [ + toPosix(path.join(projectRoot, 'src/**/*.cy.ts')), + toPosix(supportFile), + toPosix(path.join(projectRoot, 'node_modules/cypress/types/index.d.ts')), + ], + }) }