1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const fs = require('fs');
|
13 | const paths = require('../config/paths');
|
14 |
|
15 | module.exports = (resolve, rootDir, isEjecting) => {
|
16 |
|
17 |
|
18 | const setupTestsFile = fs.existsSync(paths.testsSetup) ? `<rootDir>/src/setupTests${path.extname(paths.testsSetup)}` : undefined;
|
19 |
|
20 |
|
21 |
|
22 | const config = {
|
23 | collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'],
|
24 | setupFiles: [resolve('config/polyfills.js')],
|
25 | setupTestFrameworkScriptFile: setupTestsFile,
|
26 | testPathIgnorePatterns: [
|
27 | '<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]'
|
28 | ],
|
29 | testEnvironment: 'node',
|
30 | testURL: 'http://localhost',
|
31 | transform: {
|
32 | '^.+\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest/preprocessor.js',
|
33 | '^.+\\.(js|jsx)$': isEjecting ?
|
34 | '<rootDir>/node_modules/babel-jest'
|
35 | : resolve('config/jest/babelTransform.js'),
|
36 | '^.+\\.(scss|css)$': resolve('config/jest/cssTransform.js'),
|
37 | '^(?!.*\\.(ts|tsx|js|jsx|scss|css|json)$)': resolve('config/jest/fileTransform.js'),
|
38 | },
|
39 | transformIgnorePatterns: [
|
40 | '[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'
|
41 | ],
|
42 | moduleNameMapper: {
|
43 | '^react-native$': 'react-native-web'
|
44 | },
|
45 | moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
|
46 | testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js|jsx)$'
|
47 | };
|
48 | if (rootDir) {
|
49 | config.rootDir = rootDir;
|
50 | }
|
51 | return config;
|
52 | };
|