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