-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
jest.config.js
120 lines (116 loc) · 3.34 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
120
process.env.ANANSI_JEST_BABELCONFIG = 'babel.config.js';
process.env.ANANSI_JEST_TSCONFIG = 'tsconfig.test.json';
const baseConfig = {
preset: '@anansi/jest-preset',
moduleFileExtensions: [
'ts',
'tsx',
'cts',
'mts',
'mtsx',
'js',
'jsx',
'mjs',
'cjs',
'json',
],
coveragePathIgnorePatterns: [
'node_modules',
'/__tests__',
'DevtoolsManager',
'packages/test',
'packages/graphql',
'packages/ssr',
'packages/rest/src/next',
'packages/core/src/next',
'packages/react/src/next',
'packages/react/src/server',
'packages/react/src/components/DevToolsButton.tsx',
],
testEnvironmentOptions: {
url: 'http://localhost',
},
/** TODO: Remove once we move to 'publishConfig' */
moduleNameMapper: {
'@data-client/react/redux$': ['<rootDir>/packages/react/src/server/redux'],
'@data-client/([^/]+)(/.*|[^/]*)$': ['<rootDir>/packages/$1/src$2'],
},
};
const packages = [
'endpoint',
'rest',
'graphql',
'core',
'react',
'normalizr',
'use-enhanced-reducer',
'img',
'test',
];
const projects = [
{
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
displayName: 'ReactDOM',
setupFiles: ['<rootDir>/scripts/testSetup.js'],
testEnvironment: 'jsdom',
testRegex: [
'((/__tests__/(?!.*\\.(node|native)).*)|(\\.|/)(test|spec))\\.(j|t)sx?$',
],
},
{
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
displayName: 'Node',
setupFiles: ['<rootDir>/scripts/testSetupNode.js'],
testEnvironment: 'node',
transform: {
...baseConfig.transform,
'^.+\\.(j)sx?$': [
'babel-jest',
{ rootMode: 'upward', targets: { node: 'current' } },
],
},
transformIgnorePatterns: [
'/node_modules/(?!@babel/runtime)',
'\\.pnp\\.[^\\/]+$',
'<rootDir>/.*__tests__/[^/]+\\.(web|native)\\.(j|t)sx?$',
],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.node\\.(j|t)sx?$',
},
{
// RN preset at https://github.com/facebook/react-native/blob/main/jest-preset.js
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
displayName: 'ReactNative',
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.native\\.(j|t)sx?$',
testEnvironment:
'<rootDir>/node_modules/react-native/jest/react-native-env.js',
transformIgnorePatterns: [
'node_modules\\/(?!(((jest-)?react-native)|@react-native(-community)?|react-navigation))', //from RN preset
'<rootDir>/.*__tests__/[^/]+\\.(web|node)\\.(j|t)sx?$',
'<rootDir>/scripts',
],
setupFiles: [
'<rootDir>/node_modules/react-native/jest/setup.js', //from RN preset
'<rootDir>/scripts/testSetupNative.js',
],
transform: {
//'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js', //setup.js needs to be transformed, but preprocessor screws everything else up
...baseConfig.transform,
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$':
'<rootDir>/node_modules/react-native/jest/assetFileTransformer.js', //from RN preset
},
haste: {
//from RN preset
defaultPlatform: 'ios',
platforms: ['android', 'ios', 'native'],
},
},
];
module.exports = {
projects,
};