-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathjest.js
35 lines (29 loc) · 1.23 KB
/
jest.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
#!/usr/bin/env node
/*!
* This file is necessary to allow usage of react-app-rewired as a drop-in replacement
* for react-scripts with WebStorms's test runner UI.
*
* For more information, see https://github.com/timarney/react-app-rewired/issues/182
*/
const { dependRequire } = require('../scripts/utils/dependRequire');
const spawn = dependRequire('react-dev-utils/crossSpawn');
const args = process.argv.slice(2);
// ignore --config param like it was never there
// (react-scripts adds it too and we override configuration anyway)
const configIndex = args.findIndex(x => x === '--config');
if (!!~configIndex) args.splice(configIndex, 2);
// Alternatively could be detected by presence of _INTELLIJ_JEST_CONFIG_ROOT_DIR env variable
const setupScriptFileIndex = args.findIndex(x => x === '--setupTestFrameworkScriptFile') + 1;
const isIntelliJ = !setupScriptFileIndex ? false :
args[setupScriptFileIndex].indexOf('jest-intellij-jasmine.js') !== -1;
const result = spawn.sync(
process.argv[0],
[].concat(
require.resolve('../scripts/test'),
args
), {
stdio: 'inherit',
env: Object.assign({}, process.env, isIntelliJ ? { CI: 1 } : null)
}
);
process.exit(result.signal ? 1 : result.status);