-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
jest.config.js
94 lines (87 loc) · 2.75 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
const defaults = {
rootDir: "src",
preset: "ts-jest",
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<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 react17TestFileIgnoreList = [
ignoreTSFiles,
// For now, we only support useSuspenseQuery with React 18, so no need to test
// it with React 17
'src/react/hooks/__tests__/useSuspenseQuery.test.tsx'
]
const react18TestFileIgnoreList = [
// ignore core tests (.ts files) as they are run separately
// to avoid running them twice with both react versions
// since they do not import react
ignoreTSFiles,
// failing subscriptionLink test (1)
'src/testing/react/__tests__/mockSubscriptionLink.test.tsx',
// failing hoc tests (8)
'src/react/hoc/__tests__/mutations/queries.test.tsx',
'src/react/hoc/__tests__/mutations/recycled-queries.test.tsx',
'src/react/hoc/__tests__/queries/errors.test.tsx',
'src/react/hoc/__tests__/queries/lifecycle.test.tsx',
'src/react/hoc/__tests__/queries/loading.test.tsx',
'src/react/hoc/__tests__/queries/observableQuery.test.tsx',
'src/react/hoc/__tests__/queries/skip.test.tsx',
'src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx',
// failing hooks tests (4)
'src/react/hooks/__tests__/useMutation.test.tsx',
'src/react/hooks/__tests__/useQuery.test.tsx',
'src/react/hooks/__tests__/useReactiveVar.test.tsx',
'src/react/hooks/__tests__/useSubscription.test.tsx',
// failing components tests (4)
'src/react/components/__tests__/ssr/server.test.tsx',
'src/react/components/__tests__/client/Subscription.test.tsx',
'src/react/components/__tests__/client/Mutation.test.tsx',
'src/react/components/__tests__/client/Query.test.tsx',
];
const tsStandardConfig = {
...defaults,
displayName: 'Core Tests',
testPathIgnorePatterns: [ignoreTSXFiles],
}
const standardReact18Config = {
...defaults,
displayName: "ReactDOM 18",
testPathIgnorePatterns: react18TestFileIgnoreList
};
const standardReact17Config = {
...defaults,
displayName: "ReactDOM 17",
testPathIgnorePatterns: react17TestFileIgnoreList,
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,
],
};