diff --git a/packages/angular/src/schematics/library/library.spec.ts b/packages/angular/src/schematics/library/library.spec.ts index e0176c56c515c..448f48be3a34f 100644 --- a/packages/angular/src/schematics/library/library.spec.ts +++ b/packages/angular/src/schematics/library/library.spec.ts @@ -186,7 +186,7 @@ describe('lib', () => { ]); }); - it('should leave the excludes alone when unitTestRunner is not jest', async () => { + it('should leave the excludes alone when unitTestRunner is karma', async () => { const tree = await runSchematic( 'lib', { name: 'myLib', unitTestRunner: 'karma' }, @@ -198,6 +198,19 @@ describe('lib', () => { ); expect(tsconfigJson.exclude).toEqual(['src/test.ts', '**/*.spec.ts']); }); + + it('should remove the excludes when unitTestRunner is none', async () => { + const tree = await runSchematic( + 'lib', + { name: 'myLib', unitTestRunner: 'none' }, + appTree + ); + const tsconfigJson = readJsonInTree( + tree, + 'libs/my-lib/tsconfig.lib.json' + ); + expect(tsconfigJson.exclude).toEqual([]); + }); }); it('should generate files', async () => { diff --git a/packages/angular/src/schematics/library/library.ts b/packages/angular/src/schematics/library/library.ts index 4342c50c67159..d19f554c81176 100644 --- a/packages/angular/src/schematics/library/library.ts +++ b/packages/angular/src/schematics/library/library.ts @@ -356,18 +356,21 @@ function updateProject(options: NormalizedSchema): Rule { return json; }), updateJsonInTree(`${options.projectRoot}/tsconfig.lib.json`, json => { - json.exclude = json.exclude || []; + if (options.unitTestRunner === 'jest') { + json.exclude = ['src/test-setup.ts', '**/*.spec.ts']; + } else if (options.unitTestRunner === 'none') { + json.exclude = []; + } else { + json.exclude = json.exclude || []; + } + return { ...json, extends: `./tsconfig.json`, compilerOptions: { ...json.compilerOptions, outDir: `${offsetFromRoot(options.projectRoot)}dist/out-tsc` - }, - exclude: - options.unitTestRunner === 'jest' - ? ['src/test-setup.ts', '**/*.spec.ts'] - : json.exclude || [] + } }; }), updateJsonInTree(`${options.projectRoot}/tslint.json`, json => {