1 | // @remove-on-eject-begin
|
2 | /**
|
3 | * Copyright (c) 2015-present, Facebook, Inc.
|
4 | *
|
5 | * This source code is licensed under the MIT license found in the
|
6 | * LICENSE file in the root directory of this source tree.
|
7 | */
|
8 | // @remove-on-eject-end
|
9 | ;
|
10 |
|
11 | // Do this as the first thing so that any code reading it knows the right env.
|
12 | process.env.BABEL_ENV = 'test';
|
13 | process.env.NODE_ENV = 'test';
|
14 | process.env.PUBLIC_URL = '';
|
15 |
|
16 | // Makes the script crash on unhandled rejections instead of silently
|
17 | // ignoring them. In the future, promise rejections that are not handled will
|
18 | // terminate the Node.js process with a non-zero exit code.
|
19 | process.on('unhandledRejection', err => {
|
20 | throw err;
|
21 | });
|
22 |
|
23 | // Ensure environment variables are read.
|
24 | require('../config/env');
|
25 |
|
26 | const jest = require('jest');
|
27 | const argv = process.argv.slice(2);
|
28 |
|
29 | // Watch unless on CI or in coverage mode
|
30 | if (!process.env.CI && argv.indexOf('--coverage') < 0) {
|
31 | argv.push('--watch');
|
32 | }
|
33 |
|
34 | // @remove-on-eject-begin
|
35 | // This is not necessary after eject because we embed config into package.json.
|
36 | const createJestConfig = require('./utils/createJestConfig');
|
37 | const path = require('path');
|
38 | const paths = require('../config/paths');
|
39 | argv.push(
|
40 | '--config',
|
41 | JSON.stringify(
|
42 | createJestConfig(
|
43 | relativePath => path.resolve(__dirname, '..', relativePath),
|
44 | path.resolve(paths.appSrc, '..'),
|
45 | false
|
46 | )
|
47 | )
|
48 | );
|
49 | // @remove-on-eject-end
|
50 | jest.run(argv);
|