-
Notifications
You must be signed in to change notification settings - Fork 14
/
jest.config.js
119 lines (106 loc) · 4.49 KB
/
jest.config.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const jestConfig = {
roots: ['<rootDir>'],
testEnvironment: 'node',
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
// '<rootDir>/benchmark/lib/mutative.js',
'!<rootDir>/src/inner-types.ts',
// '!<rootDir>/src/core/helper.ts',
],
setupFilesAfterEnv: [],
testMatch: [
// lastest case count: 523
'<rootDir>/test/**/*.ts',
// '<rootDir>/test/api-params/readOnly.ts',
// '<rootDir>/test/api-params/onOperate.ts',
// '<rootDir>/test/complex/scope-change.ts',
// '<rootDir>/test/complex/arr-from-set.ts',
// '<rootDir>/test/map-other/read-inner-symbol-key.ts',
// '<rootDir>/test/api/api.ts',
// '<rootDir>/test/api/immut.ts',
// '<rootDir>/test/api/limuUtils.ts',
// '<rootDir>/test/api/setAutoFreeze.ts',
// '<rootDir>/test/api/setAutoFreezeFalse.ts',
// '<rootDir>/test/immer-cases/2.{ts,js}',
// '<rootDir>/test/array-base/push.ts',
// '<rootDir>/test/array-base/slice.ts',
// '<rootDir>/test/array-other/object-item.ts',
// '<rootDir>/test/array-other/object-list.ts',
// '<rootDir>/test/array-other/print.ts',
// '<rootDir>/test/array-base/concat.ts',
// '<rootDir>/test/array-base/flatMap.ts',
// '<rootDir>/test/array-base/filter.ts',
// '<rootDir>/test/array-base/splice.ts',
// '<rootDir>/test/array-base/valueOf.ts',
// '<rootDir>/test/array-base/values.ts',
// '<rootDir>/test/array-base/map.ts',
// '<rootDir>/test/array-base/copyWithin.ts',
// '<rootDir>/test/array-base/flat.ts',
// '<rootDir>/test/array-base/unshift.ts',
// '<rootDir>/test/array-base/shift.ts',
// '<rootDir>/test/array-base/sort.ts',
// '<rootDir>/test/array-base/forEach.ts',
// '<rootDir>/test/array-base/delete.ts',
// '<rootDir>/test/array-other/case-push.ts',
// '<rootDir>/test/array-other/object-item-nested.ts',
// '<rootDir>/test/array-other/object-item.ts',
// '<rootDir>/test/array-other/object-item-2.ts',
// '<rootDir>/test/array-other/object-item-3.ts',
// '<rootDir>/test/array-other/object-list.ts',
// '<rootDir>/test/array-other/case1-of-helux.ts',
// '<rootDir>/test/map-other/case-nested-object.ts',
// '<rootDir>/test/map-other/case1.ts',
// '<rootDir>/test/map-other/case2.ts',
// '<rootDir>/test/map-other/object-map.ts',
// '<rootDir>/test/map-other/see-frozen.ts',
// '<rootDir>/test/map-base/get.ts',
// '<rootDir>/test/map-base/has.ts',
// '<rootDir>/test/map-base/keys.ts',
// '<rootDir>/test/map-base/set.ts',
// '<rootDir>/test/map-base/values.ts',
// '<rootDir>/test/map-base/forEach.ts',
// '<rootDir>/test/set-base/add.ts',
// '<rootDir>/test/set-base/forEach.ts',
// '<rootDir>/test/set-other/object-set-add.ts',
// '<rootDir>/test/set-base/keys.ts',
// '<rootDir>/test/set-base/size.ts',
// '<rootDir>/test/set-base/values.ts',
// '<rootDir>/test/set-base/clear.ts',
// '<rootDir>/test/set-other/update-object-item.ts',
// '<rootDir>/test/set-other/object-set.ts',
// '<rootDir>/test/set-other/object-set-primitive-item.ts',
// '<rootDir>/test/complex/case1.ts',
// '<rootDir>/test/complex/case-push.ts',
// '<rootDir>/test/complex/case-node-change.ts',
// '<rootDir>/test/complex/obj-value-of.ts',
// '<rootDir>/test/diff-with-immer/sort.ts',
],
testPathIgnorePatterns: ['<rootDir>/test/_util.ts', '<rootDir>/test/_data.ts'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '<rootDir>/fileTransform.js',
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$'],
modulePaths: ['<rootDir>/src'],
moduleFileExtensions: ['js', 'ts', 'json'],
collectCoverage: true,
};
const { testMatch } = process.env;
if (testMatch) {
console.log('------ found customized testMatch, start compute ------');
let prefixedTestMatch = testMatch;
// 改写前缀
if (!testMatch.startsWith('<rootDir>')) {
if (testMatch.startsWith('/')) prefixedTestMatch = `<rootDir>${testMatch}`;
else prefixedTestMatch = `<rootDir>/${testMatch}`;
}
jestConfig.testMatch = [prefixedTestMatch];
console.log(`computed testMatch: ${JSON.stringify(jestConfig.testMatch)}`);
} else {
console.log(
'Start loading the jest configuration file. If it is executed locally and you want to narrow the scope of a single test, you can add the testmatch prefix to execute it, such as',
);
// testMatch='test/yyy.ts' npm run test
console.log("testMatch='test/yyy.ts' npm run test");
}
module.exports = jestConfig;