UNPKG

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