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