fix: multi-app project extend root tsconfig.json (#11374)

This commit is contained in:
Nikolay Vitkov 2023-11-13 14:20:18 +01:00 committed by GitHub
parent 92f586cf18
commit 1b2d920fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 2 deletions

View File

@ -111,10 +111,21 @@ function getProjectBaseUrl(project: any, port: number): string {
} }
function getTsConfigPath(project: AngularProject): string { function getTsConfigPath(project: AngularProject): string {
const filename = 'tsconfig.json';
if (!project.root) { if (!project.root) {
return '../tsconfig.json'; return `../${filename}`;
} }
return `../tsconfig.app.json`;
const nested = project.root
.split('/')
.map(() => {
return '../';
})
.join('');
// Prepend a single `../` as we put the test inside `e2e` folder
return `../${nested}${filename}`;
} }
export function addCommonFiles( export function addCommonFiles(

View File

@ -93,6 +93,19 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
expect(tree.files).toContain('/e2e/tests/app.test.ts'); expect(tree.files).toContain('/e2e/tests/app.test.ts');
expect(options['testRunner']).toBe('node'); expect(options['testRunner']).toBe('node');
}); });
it('should create TypeScript files', async () => {
const tree = await buildTestingTree('ng-add', 'single');
const tsConfigPath = '/e2e/tsconfig.json';
const tsConfig = tree.readJson(tsConfigPath);
expect(tree.files).toContain(tsConfigPath);
expect(tsConfig).toMatchObject({
extends: '../tsconfig.json',
compilerOptions: {
module: 'CommonJS',
},
});
});
it('should not create port value', async () => { it('should not create port value', async () => {
const tree = await buildTestingTree('ng-add'); const tree = await buildTestingTree('ng-add');
@ -193,6 +206,19 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
); );
expect(options['testRunner']).toBe('node'); expect(options['testRunner']).toBe('node');
}); });
it('should create TypeScript files', async () => {
const tree = await buildTestingTree('ng-add', 'multi');
const tsConfigPath = getMultiApplicationFile('e2e/tsconfig.json');
const tsConfig = tree.readJson(tsConfigPath);
expect(tree.files).toContain(tsConfigPath);
expect(tsConfig).toMatchObject({
extends: '../../../tsconfig.json',
compilerOptions: {
module: 'CommonJS',
},
});
});
it('should not create port value', async () => { it('should not create port value', async () => {
const tree = await buildTestingTree('ng-add'); const tree = await buildTestingTree('ng-add');