-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathnew-workspace.test.ts
86 lines (70 loc) · 2.99 KB
/
new-workspace.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import path from 'node:path';
import { setWorkspaceRoot } from 'nx/src/utils/workspace-root';
import { FIXTURES_DIR, Fixture } from '../utils/fixtures';
import {
LONG_TIMEOUT_MS,
runNgAdd,
runNgGenerate,
runNgNew,
} from '../utils/local-registry-process';
import { runLint } from '../utils/run-lint';
import { normalizeVersionsOfPackagesWeDoNotControl } from '../utils/snapshot-serializers';
expect.addSnapshotSerializer(normalizeVersionsOfPackagesWeDoNotControl);
const fixtureDirectory = 'new-workspace';
let fixture: Fixture;
describe('new-workspace', () => {
jest.setTimeout(LONG_TIMEOUT_MS);
beforeAll(async () => {
process.chdir(FIXTURES_DIR);
await runNgNew(fixtureDirectory);
process.env.NX_DAEMON = 'false';
process.env.NX_CACHE_PROJECT_GRAPH = 'false';
const workspaceRoot = path.join(FIXTURES_DIR, fixtureDirectory);
process.chdir(workspaceRoot);
process.env.NX_WORKSPACE_ROOT_PATH = workspaceRoot;
setWorkspaceRoot(workspaceRoot);
fixture = new Fixture(workspaceRoot);
await runNgAdd();
await runNgGenerate(['app', 'another-app', '--interactive=false']);
await runNgGenerate(['lib', 'another-lib', '--interactive=false']);
});
it('should pass linting after creating a new workspace from scratch using @angular-eslint', async () => {
// TSLint configs and dependencies should not be present
expect(fixture.fileExists('tslint.json')).toBe(false);
expect(
JSON.stringify(fixture.readJson('package.json').devDependencies, null, 2),
).toMatchSnapshot();
// Root eslint config should be eslint.config.js, not eslintrc
expect(fixture.readFile('eslint.config.js')).toMatchSnapshot();
expect(fixture.fileExists('.eslintrc.json')).toBe(false);
expect(
fixture.readJson('angular.json').projects['new-workspace'].architect.lint,
).toMatchSnapshot();
// Additional project ("another-app")
expect(fixture.fileExists('projects/another-app/tslint.json')).toBe(false);
expect(
fixture.readFile('projects/another-app/eslint.config.js'),
).toMatchSnapshot();
expect(fixture.fileExists('projects/another-app/.eslintrc.json')).toBe(
false,
);
// It should contain the eslintConfig option set to the project level eslint.config.js file
expect(
fixture.readJson('angular.json').projects['another-app'].architect.lint,
).toMatchSnapshot();
// Additional library project ("another-lib")
expect(fixture.fileExists('projects/another-lib/tslint.json')).toBe(false);
expect(
fixture.readFile('projects/another-lib/eslint.config.js'),
).toMatchSnapshot();
expect(fixture.fileExists('projects/another-lib/.eslintrc.json')).toBe(
false,
);
// It should contain the eslintConfig option set to the project level eslint.config.js file
expect(
fixture.readJson('angular.json').projects['another-lib'].architect.lint,
).toMatchSnapshot();
const lintOutput = await runLint(fixtureDirectory);
expect(lintOutput).toMatchSnapshot();
});
});