forked from reactive/data-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.config.js
93 lines (87 loc) · 2.56 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
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const ts = require('typescript');
function readTsConfig(path = './', configName = 'tsconfig.json') {
const parseConfigHost = {
fileExists: ts.sys.fileExists,
readFile: ts.sys.readFile,
readDirectory: ts.sys.readDirectory,
useCaseSensitiveFileNames: true,
};
const configFileName = ts.findConfigFile(path, ts.sys.fileExists, configName);
const configFile = ts.readConfigFile(configFileName, ts.sys.readFile);
const compilerOptions = ts.parseJsonConfigFileContent(
configFile.config,
parseConfigHost,
path,
);
return compilerOptions;
}
const baseConfig = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.(j)sx?$': ['babel-jest', { rootMode: 'upward' }],
},
globals: {
'ts-jest': {
babelConfig: 'babel.config.js',
tsConfig: '<rootDir>/tsconfig.test.json',
},
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(j|t)sx?$',
coveragePathIgnorePatterns: [
'node_modules',
'react-integration/hooks/useSelection',
'packages/test',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
moduleNameMapper: {
...pathsToModuleNameMapper(
readTsConfig('./', 'tsconfig.test.json').options.paths,
{
prefix: '<rootDir>/',
},
),
},
testURL: 'http://localhost',
};
const packages = [
'legacy',
'endpoint',
'core',
'rest-hooks',
'normalizr',
'use-enhanced-reducer',
];
const projects = [
{
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
displayName: 'ReactDOM',
setupFiles: ['<rootDir>/scripts/testSetup.js'],
},
/*{
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
displayName: 'React Native',
preset: 'react-native',
transformIgnorePatterns: [
'/node_modules/(?!(jest-)?react-native|@react-native-community)', //from RN preset
'<rootDir>/.*__tests__/[^/]+\\.web\\.(j|t)sx?$',
],
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
},
},*/
];
module.exports = {
projects,
};