-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathjest.config.ts
47 lines (39 loc) · 1.32 KB
/
jest.config.ts
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
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./test/typings/environment.d.ts" />
import type { Config } from 'jest';
import getReactMajorVersion from './test/util/get-react-major-version';
import isRunningInCI from './test/util/is-running-in-ci';
const reactMajorVersion = getReactMajorVersion();
const config: Config = {
clearMocks: true,
modulePathIgnorePatterns: ['/dist/'],
resetMocks: true,
resetModules: true,
restoreMocks: true,
setupFiles: ['./test/setup/env-setup.ts'],
setupFilesAfterEnv: ['./test/setup/test-setup.ts'],
testEnvironment: './test/setup/environment.ts',
// node_modules is default.
testPathIgnorePatterns: ['/node_modules/', '/cypress/'],
transform: {
'\\.[jt]sx?$': 'babel-jest',
},
verbose: true,
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
};
// eslint-disable-next-line no-console
console.log('Testing with React version:', `${reactMajorVersion}.x.x`);
if (reactMajorVersion === '18') {
config.cacheDirectory = `.cache/jest-cache-react-${reactMajorVersion}`;
config.moduleNameMapper = {
'^react-dom((\\/.*)?)$': `react-dom-${reactMajorVersion}$1`,
'^react((\\/.*)?)$': `react-${reactMajorVersion}$1`,
};
}
if (isRunningInCI()) {
config.maxWorkers = 2;
}
export default config;