-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
jest.config.js
99 lines (95 loc) · 2.45 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
/*
* Copyright: (c) 2024, Alex Kaul
* GNU General Public License v3.0 or later (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
*/
const baseConfig = {
testMatch: [
'**/*.spec.(js|jsx|ts|tsx)'
],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
transformIgnorePatterns: [
'node_modules/(?!uuid/)'
]
}
const makeModuleNameMapper = m => ({
...((m !== 'common' && m !== 'test-utils') ? { '@/(.*)': `<rootDir>/src/${m}/$1` } : {}),
'@common/(.*)': '<rootDir>/src/common/$1',
...((m !== 'test-utils') ? { '@tests/(.*)': `<rootDir>/tests/${m}/$1` } : {}),
...((m !== 'test-utils') ? { '@testscommon/(.*)': '<rootDir>/tests/common/$1' } : {}),
'@utils/(.*)': '<rootDir>/tests/utils/$1',
})
module.exports = {
projects: [{
...baseConfig,
testEnvironment: 'node',
displayName: {
name: 'Main',
color: 'blue'
},
moduleNameMapper: {
...makeModuleNameMapper('main')
},
roots: ['<rootDir>/tests/main/', '<rootDir>/src/main/']
}, {
...baseConfig,
testEnvironment: 'jsdom',
displayName: {
name: 'Renderer',
color: 'magenta'
},
setupFilesAfterEnv: ['<rootDir>/tests/renderer/setupTests.ts'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/tests/__mocks__/fileMock.js',
'\\.(css|less|scss)$': '<rootDir>/tests/__mocks__/identity-obj-proxy.js',
...makeModuleNameMapper('renderer')
},
roots: ['<rootDir>/tests/renderer/', '<rootDir>/src/renderer/']
}, {
...baseConfig,
testEnvironment: 'node',
displayName: {
name: 'Common',
color: 'cyan'
},
moduleNameMapper: {
...makeModuleNameMapper('common')
},
roots: ['<rootDir>/tests/common/', '<rootDir>/src/common/']
}, {
...baseConfig,
testEnvironment: 'node',
displayName: {
name: 'Test Utils',
color: 'yellow'
},
moduleNameMapper: {
...makeModuleNameMapper('test-utils')
},
roots: ['<rootDir>/tests/utils/']
}],
coverageProvider: 'v8',
collectCoverageFrom: [
'**/*.{js,jsx,ts,tsx}',
'!build/**',
'!**/*.d.ts',
'!**/index.ts',
'!**/interfaces/**',
'!**/node_modules/**',
'!tests/**',
'tests/utils/**',
'!tests/utils/**/*.spec.{ts,tsx}',
],
};