Skip to content

Commit 40c6807

Browse files
committed
fix(@schematics/angular): do not generate tsconfig.spec.json when tests are skipped
with `skipTests` application schematic already leaves out test target, spec reference in root `tsconfig.json`, test runner dependencies and spec files, yet it still wrote `tsconfig.spec.json` that no target or tsconfig refrences file is now filtered out for `skipTests` same way as for `minimal`, so `ng new --skip-tests` and `ng g app --skip-tests` no longer leave it behind `"test": "ng test"` script in workspace `package.json` is still added, workspace schematic has no `skipTests` option Refs #9160
1 parent 193abc0 commit 40c6807

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/schematics/angular/application/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function (options: ApplicationOptions): Rule {
121121
),
122122
mergeWith(
123123
apply(url('./files/common-files'), [
124-
options.minimal
124+
options.skipTests || options.minimal
125125
? filter((path) => !path.endsWith('tsconfig.spec.json.template'))
126126
: noop(),
127127
componentOptions.inlineTemplate

‎packages/schematics/angular/application/index_spec.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ describe('Application Schematic', () => {
157157
);
158158
});
159159

160+
it('should not create tsconfig.spec.json with "skipTests" enabled', async () => {
161+
const tree = await schematicRunner.runSchematic(
162+
'application',
163+
{ ...defaultOptions, skipTests: true },
164+
workspaceTree,
165+
);
166+
167+
expect(tree.exists('/projects/foo/tsconfig.app.json')).toBeTrue();
168+
expect(tree.exists('/projects/foo/tsconfig.spec.json')).toBeFalse();
169+
});
170+
160171
it('should not add spec project reference in the root tsconfig.json with "minimal" enabled', async () => {
161172
const tree = await schematicRunner.runSchematic(
162173
'application',

0 commit comments

Comments
 (0)