-
Notifications
You must be signed in to change notification settings - Fork 304
/
ng-jest-config.spec.ts
81 lines (73 loc) · 2.77 KB
/
ng-jest-config.spec.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
import { normalizeSeparators } from '@angular/compiler-cli/src/ngtsc/util/src/path';
import { join } from 'path';
import { NgJestConfig } from '../config/ng-jest-config';
describe('NgJestConfig', () => {
const specifiedTsCfgPath = join(__dirname, '..', '..', 'tsconfig.spec.json');
const defaultTsCfgPath = join(__dirname, '..', '..', 'tsconfig.json');
describe('_resolveTsConfig', () => {
test('should return config including Angular compiler config with tsconfig as a string from ts-jest option', () => {
const ngJestConfig = new NgJestConfig({
testMatch: [],
testRegex: [],
extensionsToTreatAsEsm: [],
globals: {
'ts-jest': {
tsconfig: specifiedTsCfgPath,
},
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
const config = ngJestConfig.parsedTsConfig;
delete config.options.basePath;
delete config.options.baseUrl;
expect(config.options.configFilePath).toEqual(normalizeSeparators(specifiedTsCfgPath));
delete config.options.configFilePath;
delete config.options.genDir;
expect(config.options).toMatchSnapshot();
});
test.each([
{},
{
skipLibCheck: false,
},
])(
'should return config including Angular compiler config with tsconfig as an object from ts-jest option',
(tsconfig) => {
const ngJestConfig = new NgJestConfig({
cwd: '.',
testMatch: [],
testRegex: [],
extensionsToTreatAsEsm: [],
globals: {
'ts-jest': {
tsconfig,
},
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
const config = ngJestConfig.parsedTsConfig;
delete config.options.basePath;
delete config.options.baseUrl;
expect(config.options.configFilePath).toEqual(normalizeSeparators(defaultTsCfgPath));
delete config.options.configFilePath;
delete config.options.genDir;
expect(config.options).toMatchSnapshot();
},
);
test('should return config including Angular compiler config without tsconfig defined in ts-jest option', () => {
const ngJestConfig = new NgJestConfig({
testMatch: [],
testRegex: [],
extensionsToTreatAsEsm: [],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
const config = ngJestConfig.parsedTsConfig;
delete config.options.basePath;
delete config.options.baseUrl;
expect(config.options.configFilePath).toEqual(normalizeSeparators(defaultTsCfgPath));
delete config.options.configFilePath;
delete config.options.genDir;
expect(config.options).toMatchSnapshot();
});
});
});