-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
jest.config.js
61 lines (56 loc) · 1.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
const defaults = {
rootDir: "src",
preset: "ts-jest",
testEnvironment: "jsdom",
setupFiles: ["<rootDir>/config/jest/setup.ts"],
testEnvironmentOptions: {
url: "http://localhost",
},
snapshotFormat: {
escapeString: true,
printBasicPrototype: true
},
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
warnOnly: process.env.TEST_ENV !== 'ci'
},
},
],
},
};
const ignoreTSFiles = '.ts$';
const ignoreTSXFiles = '.tsx$';
const tsStandardConfig = {
...defaults,
displayName: 'Core Tests',
testPathIgnorePatterns: [ignoreTSXFiles],
}
// For both React (Jest) "projects", ignore core tests (.ts files) as they
// do not import React, to avoid running them twice.
const standardReact18Config = {
...defaults,
displayName: "ReactDOM 18",
testPathIgnorePatterns: [ignoreTSFiles],
};
const standardReact17Config = {
...defaults,
displayName: "ReactDOM 17",
testPathIgnorePatterns: [ignoreTSFiles],
moduleNameMapper: {
"^react$": "react-17",
"^react-dom$": "react-dom-17",
"^react-dom/server$": "react-dom-17/server",
"^react-dom/test-utils$": "react-dom-17/test-utils",
"^@testing-library/react$": "@testing-library/react-12",
},
};
module.exports = {
projects: [
tsStandardConfig,
standardReact17Config,
standardReact18Config,
],
};