-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
60 lines (55 loc) · 1.11 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
const jestDefaultConfig = {
clearMocks: true,
resetMocks: true,
restoreMocks: true,
rootDir: '.',
roots: ['<rootDir>/src'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
};
const web = {
...jestDefaultConfig,
displayName: {
name: 'Web',
color: 'cyan',
},
testMatch: ['**/__tests__/**/*.(spec|test).ts?(x)'],
transform: {
'^.+\\.tsx?$': '@swc/jest',
},
testEnvironment: 'jsdom',
};
const server = {
...jestDefaultConfig,
displayName: {
name: 'Server',
color: 'blue',
},
testMatch: ['**/+([a-zA-Z]).server.(spec|test).ts?(x)'],
transform: {
'^.+\\.tsx?$': '@swc/jest',
},
testEnvironment: 'node',
};
const getProjects = () => {
const testEnv = process.env.TEST_ENV;
if (!testEnv) {
return [web, server];
}
switch (testEnv) {
case 'web':
return [web];
case 'server':
return [server];
}
};
module.exports = {
collectCoverageFrom: [
'**/**/*.{ts,tsx}',
'!**/**/*.test.{ts,tsx}',
'!**/src/types/**',
'!**/node_modules/**',
'!**/dist/**',
'!**/__tests__/**',
],
projects: getProjects(),
};