-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
52 lines (47 loc) · 1.17 KB
/
jest.config.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
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
type ITestType = 'test:unit' | 'test:e2e' | 'updateSnapshot'
const testTypeMap = {
'test:unit': {
subfix: '.unit.test.js',
preset: 'ts-jest'
},
updateSnapshot: {
subfix: '.unit.test.js',
preset: 'ts-jest'
},
'test:e2e': {
subfix: '.e2e.test.js',
preset: 'jest-puppeteer'
}
}
const testType = process.env.npm_lifecycle_event as ITestType
const testMatch = [
"**/__tests__/**/user.unit.test.js",
"**/__tests__/**/user.e2e.test.js"
].filter(item => item.indexOf(testTypeMap[testType].subfix) > -1)
export default {
preset: testTypeMap[testType].preset,
testEnvironment: 'jsdom',
testMatch,
collectCoverage: true,
coverageDirectory: 'coverage',
collectCoverageFrom: [
'./src/components/**/*.tsx'
],
coverageReporters: ['html', 'lcov', 'text'],
verbose: true,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
transform: {
"^.+\\.[t|j]sx?$": "babel-jest"
},
rootDir: '.',
// moduleNameMapper: {
// "/^@/": '<rootDir>/src'
// }
setupFiles: [
'./tests/setup.js'
]
}