-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
58 lines (50 loc) · 1.31 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
const { defaults: tsjPreset } = require('ts-jest/presets')
const defaults = {
coverageDirectory: './coverage/',
collectCoverage: true,
testURL: 'http://localhost',
}
const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils']
const tsTestFolderPath = (folderName) =>
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`
const tsStandardConfig = {
...defaults,
displayName: 'ReactDOM 18 (Shim)',
preset: 'ts-jest',
testMatch: NORMAL_TEST_FOLDERS.map(tsTestFolderPath),
}
const rnConfig = {
...defaults,
displayName: 'React Native',
testMatch: [tsTestFolderPath('react-native')],
preset: 'react-native',
transform: {
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
...tsjPreset.transform,
},
}
const standardReact17Config = {
...tsStandardConfig,
displayName: 'ReactDOM 17',
moduleNameMapper: {
'^react$': 'react-17',
'^react-dom$': 'react-dom-17',
'^react-test-renderer$': 'react-test-renderer-17',
'^@testing-library/react$': '@testing-library/react-12',
},
}
const nextEntryConfig = {
...tsStandardConfig,
displayName: 'ReactDOM 18 (Next)',
moduleNameMapper: {
'../../src/index': '<rootDir>/src/next',
},
}
module.exports = {
projects: [
tsStandardConfig,
rnConfig,
standardReact17Config,
nextEntryConfig,
],
}