fix(angular): remove tsconfig.lib.json excludes when --unit-test-runner is none

This commit is contained in:
Bucky Maler 2019-09-16 22:12:19 -05:00 committed by Victor Savkin
parent 47e751f931
commit fa05f1171a
2 changed files with 23 additions and 7 deletions

View File

@ -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 () => {

View File

@ -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 => {