From fa05f1171a7dc09e3fb695d94b098f142f14562e Mon Sep 17 00:00:00 2001 From: Bucky Maler Date: Mon, 16 Sep 2019 22:12:19 -0500 Subject: [PATCH] fix(angular): remove tsconfig.lib.json excludes when --unit-test-runner is none --- .../src/schematics/library/library.spec.ts | 15 ++++++++++++++- .../angular/src/schematics/library/library.ts | 15 +++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) 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 => {