fix(angular): remove tsconfig.lib.json excludes when --unit-test-runner is none
This commit is contained in:
parent
47e751f931
commit
fa05f1171a
@ -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(
|
const tree = await runSchematic(
|
||||||
'lib',
|
'lib',
|
||||||
{ name: 'myLib', unitTestRunner: 'karma' },
|
{ name: 'myLib', unitTestRunner: 'karma' },
|
||||||
@ -198,6 +198,19 @@ describe('lib', () => {
|
|||||||
);
|
);
|
||||||
expect(tsconfigJson.exclude).toEqual(['src/test.ts', '**/*.spec.ts']);
|
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 () => {
|
it('should generate files', async () => {
|
||||||
|
|||||||
@ -356,18 +356,21 @@ function updateProject(options: NormalizedSchema): Rule {
|
|||||||
return json;
|
return json;
|
||||||
}),
|
}),
|
||||||
updateJsonInTree(`${options.projectRoot}/tsconfig.lib.json`, json => {
|
updateJsonInTree(`${options.projectRoot}/tsconfig.lib.json`, json => {
|
||||||
|
if (options.unitTestRunner === 'jest') {
|
||||||
|
json.exclude = ['src/test-setup.ts', '**/*.spec.ts'];
|
||||||
|
} else if (options.unitTestRunner === 'none') {
|
||||||
|
json.exclude = [];
|
||||||
|
} else {
|
||||||
json.exclude = json.exclude || [];
|
json.exclude = json.exclude || [];
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...json,
|
...json,
|
||||||
extends: `./tsconfig.json`,
|
extends: `./tsconfig.json`,
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
...json.compilerOptions,
|
...json.compilerOptions,
|
||||||
outDir: `${offsetFromRoot(options.projectRoot)}dist/out-tsc`
|
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 => {
|
updateJsonInTree(`${options.projectRoot}/tslint.json`, json => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user