1 | 'use strict';
|
2 |
|
3 | process.env.NODE_ENV = 'test';
|
4 |
|
5 | const jest = require('jest');
|
6 | const path = require('path');
|
7 | const pathExists = require('path-exists');
|
8 | const argv = process.argv.slice(2);
|
9 |
|
10 |
|
11 | if (!process.env.CI) {
|
12 | argv.push('--watch');
|
13 | }
|
14 |
|
15 | const rootDir = process.cwd();
|
16 | const setupTestsFile = pathExists.sync(path.resolve(rootDir, './src/setupTests.js')) ? '<rootDir>/src/setupTests.js' : undefined;
|
17 |
|
18 | argv.push('--config', JSON.stringify({
|
19 | rootDir,
|
20 | moduleFileExtensions: ['jsx', 'js', 'json'],
|
21 | moduleNameMapper: {
|
22 | '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': require.resolve('./jest/file.stub.js'),
|
23 | '^.+\\.css$': require.resolve('./jest/css.stub.js')
|
24 | },
|
25 | scriptPreprocessor: require.resolve('./jest/transform.js'),
|
26 | setupFiles: [],
|
27 | setupTestFrameworkScriptFile: setupTestsFile,
|
28 | testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
|
29 | testEnvironment: argv.indexOf('--node') !== -1 ? 'node' : 'jsdom',
|
30 | testRegex: argv.indexOf('--node') !== -1 ? '(/__tests_node__/.*|\\.(test\\.node|spec\\.node))\\.(js|jsx)$' : '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$'
|
31 | }));
|
32 |
|
33 | jest.run(argv); |
\ | No newline at end of file |