Skip to content

Commit

Permalink
cleanup(angular): remove tsconfig.spec.json handling from application…
Browse files Browse the repository at this point in the history
… generator (#15731)
  • Loading branch information
leosvelperez committed Mar 20, 2023
1 parent 9ef2dd9 commit e9b5181
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ Object {
}
`;
exports[`app not nested should generate files 1`] = `
exports[`app not nested should generate files: e2e tsconfig.json 1`] = `
Object {
"compilerOptions": Object {
"allowJs": true,
Expand All @@ -527,3 +527,59 @@ Object {
],
}
`;
exports[`app not nested should generate files: tsconfig.app.json 1`] = `
Object {
"compilerOptions": Object {
"outDir": "../../dist/out-tsc",
"types": Array [],
},
"exclude": Array [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
],
"extends": "./tsconfig.json",
"files": Array [
"src/main.ts",
],
"include": Array [
"src/**/*.d.ts",
],
}
`;
exports[`app not nested should generate files: tsconfig.json 1`] = `
Object {
"angularCompilerOptions": Object {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true,
},
"compilerOptions": Object {
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"strict": true,
"target": "es2022",
"useDefineForClassFields": false,
},
"extends": "../../tsconfig.base.json",
"files": Array [],
"include": Array [],
"references": Array [
Object {
"path": "./tsconfig.app.json",
},
Object {
"path": "./tsconfig.spec.json",
},
Object {
"path": "./tsconfig.editor.json",
},
],
}
`;
37 changes: 19 additions & 18 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,14 @@ describe('app', () => {
appTree.read('apps/my-app/src/app/app.module.ts', 'utf-8')
).toContain('class AppModule');

const tsconfig = readJson(appTree, 'apps/my-app/tsconfig.json');
expect(tsconfig.references).toContainEqual({
path: './tsconfig.app.json',
});
expect(tsconfig.references).toContainEqual({
path: './tsconfig.spec.json',
});
expect(tsconfig.references).toContainEqual({
path: './tsconfig.editor.json',
});
expect(readJson(appTree, 'apps/my-app/tsconfig.json')).toMatchSnapshot(
'tsconfig.json'
);

const tsconfigApp = parseJson(
appTree.read('apps/my-app/tsconfig.app.json', 'utf-8')
);
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
expect(tsconfigApp.extends).toEqual('./tsconfig.json');
expect(tsconfigApp.exclude).toEqual([
'jest.config.ts',
'src/**/*.test.ts',
'src/**/*.spec.ts',
]);
expect(tsconfigApp).toMatchSnapshot('tsconfig.app.json');

const eslintrcJson = parseJson(
appTree.read('apps/my-app/.eslintrc.json', 'utf-8')
Expand All @@ -138,7 +125,7 @@ describe('app', () => {
const tsconfigE2E = parseJson(
appTree.read('apps/my-app-e2e/tsconfig.json', 'utf-8')
);
expect(tsconfigE2E).toMatchSnapshot();
expect(tsconfigE2E).toMatchSnapshot('e2e tsconfig.json');
});

it('should setup jest with serializers', async () => {
Expand Down Expand Up @@ -586,6 +573,15 @@ describe('app', () => {
`'jest-preset-angular/build/serializers/html-comment'`
);
});

it('should add reference to tsconfig.spec.json to tsconfig.json', async () => {
await generateApp(appTree);

const { references } = readJson(appTree, 'apps/my-app/tsconfig.json');
expect(
references.find((r) => r.path.includes('tsconfig.spec.json'))
).toBeTruthy();
});
});

describe('none', () => {
Expand All @@ -604,6 +600,11 @@ describe('app', () => {
expect(
readProjectConfiguration(appTree, 'my-app').targets.test
).toBeUndefined();
// check tsconfig.spec.json is not referenced
const { references } = readJson(appTree, 'apps/my-app/tsconfig.json');
expect(
references.every((r) => !r.path.includes('tsconfig.spec.json'))
).toBe(true);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
"references": [
{
"path": "./tsconfig.app.json"
},
<% if(unitTesting) { %>{
"path": "./tsconfig.spec.json"
},<% } %>
{
"path": "./tsconfig.editor.json"
}
],
"extends": "<%= rootTsConfig %>"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ export async function createFiles(
);
}

if (options.unitTestRunner === UnitTestRunner.None) {
tree.delete(
joinPathFragments(options.appProjectRoot, 'tsconfig.spec.json')
);
}

if (options.inlineTemplate) {
tree.delete(
joinPathFragments(options.appProjectRoot, '/src/app/app.component.html')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Array [
"tsconfig.app.json",
"tsconfig.editor.json",
"tsconfig.json",
"tsconfig.spec.json",
".eslintrc.json",
"jest.config.ts",
"tsconfig.spec.json",
]
`;

Expand Down

1 comment on commit e9b5181

@vercel
Copy link

@vercel vercel bot commented on e9b5181 Mar 20, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.