fix(angular): fix error when creating angular lib with eslint and karma (#4264)
ISSUES CLOSED: #4256
This commit is contained in:
parent
f70fa2d78f
commit
b4dd8c6ffb
@ -1,7 +1,7 @@
|
||||
import { Tree } from '@angular-devkit/schematics';
|
||||
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
|
||||
import { runSchematic } from '../../utils/testing';
|
||||
import { readJsonInTree } from '@nrwl/workspace';
|
||||
import { Linter, readJsonInTree } from '@nrwl/workspace';
|
||||
|
||||
describe('karmaProject', () => {
|
||||
let appTree: Tree;
|
||||
@ -202,4 +202,40 @@ module.exports = function(config) {
|
||||
expect(testTs).not.toContain("import 'zone.js/dist/zone';");
|
||||
});
|
||||
});
|
||||
|
||||
describe('linter', () => {
|
||||
it('should work with eslint as linter', async () => {
|
||||
const resultTree = await runSchematic(
|
||||
'lib',
|
||||
{
|
||||
name: 'lib-with-eslint-and-karma',
|
||||
unitTestRunner: 'karma',
|
||||
linter: Linter.EsLint,
|
||||
},
|
||||
appTree
|
||||
);
|
||||
const workspaceJson = readJsonInTree(resultTree, 'workspace.json');
|
||||
|
||||
expect(
|
||||
workspaceJson.projects['lib-with-eslint-and-karma'].architect.lint
|
||||
.options.tsConfig
|
||||
).toBeUndefined();
|
||||
|
||||
expect(
|
||||
workspaceJson.projects['lib-with-eslint-and-karma'].architect.lint
|
||||
.builder
|
||||
).toBe('@nrwl/linter:eslint');
|
||||
|
||||
expect(
|
||||
workspaceJson.projects['lib-with-eslint-and-karma'].architect.test
|
||||
).toEqual({
|
||||
builder: '@angular-devkit/build-angular:karma',
|
||||
options: {
|
||||
main: 'libs/lib-with-eslint-and-karma/src/test.ts',
|
||||
tsConfig: 'libs/lib-with-eslint-and-karma/tsconfig.spec.json',
|
||||
karmaConfig: 'libs/lib-with-eslint-and-karma/karma.conf.js',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -99,7 +99,12 @@ function updateworkspaceJson(options: KarmaProjectSchema): Rule {
|
||||
assets: [],
|
||||
};
|
||||
}
|
||||
if (projectConfig.architect.lint) {
|
||||
|
||||
if (
|
||||
projectConfig.architect.lint &&
|
||||
projectConfig.architect.lint.builder ===
|
||||
'@angular-devkit/build-angular:tslint'
|
||||
) {
|
||||
projectConfig.architect.lint.options.tsConfig = [
|
||||
...projectConfig.architect.lint.options.tsConfig,
|
||||
join(normalize(projectConfig.root), 'tsconfig.spec.json'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user