Skip to content

Commit 0f7dc2c

Browse files
clydinjkrems
authored andcommitted
fix(@schematics/angular): skip spec project reference for minimal ng new
When generating a new project with `ng new` and the `minimal` option, a Typescript project reference to a `tsconfig.spec.json` should not be present since that file is not created with a minimal project.
1 parent 8a18dcd commit 0f7dc2c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/schematics/angular/application/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function (options: ApplicationOptions): Rule {
5656
return chain([
5757
addAppToWorkspaceFile(options, appDir, folderName),
5858
addTsProjectReference('./' + join(normalize(appDir), 'tsconfig.app.json')),
59-
options.skipTests
59+
options.skipTests || options.minimal
6060
? noop()
6161
: addTsProjectReference('./' + join(normalize(appDir), 'tsconfig.spec.json')),
6262
options.standalone

packages/schematics/angular/application/index_spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ describe('Application Schematic', () => {
138138
);
139139
});
140140

141+
it('should not add spec project reference in the root tsconfig.json with "minimal" enabled', async () => {
142+
const tree = await schematicRunner.runSchematic(
143+
'application',
144+
{ ...defaultOptions, minimal: true },
145+
workspaceTree,
146+
);
147+
148+
const { references } = readJsonFile(tree, '/tsconfig.json');
149+
expect(references).toContain(
150+
jasmine.objectContaining({ path: './projects/foo/tsconfig.app.json' }),
151+
);
152+
expect(references).not.toContain(
153+
jasmine.objectContaining({ path: './projects/foo/tsconfig.spec.json' }),
154+
);
155+
});
156+
141157
it('should install npm dependencies when `skipInstall` is false', async () => {
142158
await schematicRunner.runSchematic(
143159
'application',

0 commit comments

Comments
 (0)