-
Notifications
You must be signed in to change notification settings - Fork 12
/
jest.config.base.js
93 lines (93 loc) · 3.33 KB
/
jest.config.base.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
/**
* @type {import('jest').Config}
*/
module.exports = {
rootDir: '.',
modulePaths: ['<rootDir>/'],
// @FIXME: It would be nice to generate `moduleNameMapper` dynamically, but is is not easily possible
// due to our `exports` field definitions in package.json files. But maybe YOU can figure it out and send PR?
moduleNameMapper: {
// @ima/testing-library is using this import to get the main application file
// It would map to the transpiled file by default, but we want to use the source file here
'^app/main$': '<rootDir>/../testing-library/src/client/app/main',
// Map all packages to their source entry points
'^@ima/cli$': '<rootDir>/../cli/src/index',
'^@ima/core$': '<rootDir>/../core/src/index',
'^@ima/core/setupJest.js$': '<rootDir>/../core/setupJest',
'^@ima/dev-utils/(.*)$': '<rootDir>/../dev-utils/src/$1',
'^@ima/error-overlay$': '<rootDir>/../error-overlay/src/index',
'^@ima/helpers$': '<rootDir>/../helpers/src/index',
'^@ima/hmr-client$': '<rootDir>/../hmr-client/src/index',
'^@ima/plugin-cli$': '<rootDir>/../plugin-cli/src/index',
'^@ima/react-page-renderer$': '<rootDir>/../react-page-renderer/src/index',
'^@ima/react-page-renderer/renderer/(.*)$':
'<rootDir>/../react-page-renderer/src/renderer/$1',
'^@ima/react-page-renderer/hook/(.*)$':
'<rootDir>/../react-page-renderer/src/hook/$1',
'^@ima/storybook-integration$':
'<rootDir>/../storybook-integration/src/index',
'^@ima/storybook-integration/preset$':
'<rootDir>/../storybook-integration/src/preset',
'^@ima/storybook-integration/preview$':
'<rootDir>/../storybook-integration/src/preview',
'^@ima/storybook-integration/helpers$':
'<rootDir>/../storybook-integration/src/helpers/index',
'^@ima/testing-library$': '<rootDir>/../testing-library/src/index',
'^@ima/testing-library/client$':
'<rootDir>/../testing-library/src/client/index',
'^@ima/testing-library/server$':
'<rootDir>/../testing-library/src/server/index',
'^@ima/testing-library/fallback/app/main$':
'<rootDir>/../testing-library/src/client/app/main',
'^@ima/testing-library/fallback/server/(.*)$':
'<rootDir>/../testing-library/src/server/$1',
'^@ima/testing-library/jest-preset$':
'<rootDir>/../testing-library/src/jest-preset',
'^@ima/testing-library/jestSetupFileAfterEnv$':
'<rootDir>/../testing-library/src/jestSetupFileAfterEnv',
},
setupFiles: ['<rootDir>/setupJest.js'],
testRegex: '(/__tests__/).*Spec\\.jsx?$',
transform: {
'^.+\\.(js|jsx)$': [
'@swc/jest',
{
jsc: {
experimental: {
plugins: [['swc_mut_cjs_exports', {}]],
},
target: 'es2022',
parser: {
syntax: 'ecmascript',
jsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
'^.+\\.(ts|tsx)$': [
'@swc/jest',
{
jsc: {
experimental: {
plugins: [['swc_mut_cjs_exports', {}]],
},
target: 'es2022',
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
};