UNPKG

1.43 kBJavaScriptView Raw
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'use strict';
10
11// Do this as the first thing so that any code reading it knows the right env.
12process.env.BABEL_ENV = 'test';
13process.env.NODE_ENV = 'test';
14process.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.
19process.on('unhandledRejection', err => {
20 throw err;
21});
22
23// Ensure environment variables are read.
24require('../config/env');
25
26const jest = require('jest');
27const argv = process.argv.slice(2);
28
29// Watch unless on CI or in coverage mode
30if (!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.
36const createJestConfig = require('./utils/createJestConfig');
37const path = require('path');
38const paths = require('../config/paths');
39argv.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
50jest.run(argv);