forked from reactive/data-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
63 lines (57 loc) · 1.59 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
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?$': '<rootDir>/scripts/babel-jest',
},
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>/',
},
),
},
setupFiles: ['<rootDir>/scripts/testSetup.js'],
};
const packages = ['legacy', 'rest-hooks', 'normalizr', 'use-enhanced-reducer'];
const projects = [
{
...baseConfig,
rootDir: __dirname,
roots: packages.map(pkgName => `<rootDir>/packages/${pkgName}/src`),
},
];
module.exports = {
projects,
};