UNPKG

1.64 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
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// Load environment variables from .env file. Suppress warnings using silent
24// if this file is missing. dotenv will never modify any environment variables
25// that have already been set.
26// https://github.com/motdotla/dotenv
27require('dotenv').config({ silent: true });
28
29const jest = require('jest');
30const argv = process.argv.slice(2);
31
32// Watch unless on CI or in coverage mode
33if (!process.env.CI && argv.indexOf('--coverage') < 0) {
34 argv.push('--watch');
35}
36
37// @remove-on-eject-begin
38// This is not necessary after eject because we embed config into package.json.
39const createJestConfig = require('./utils/createJestConfig');
40const path = require('path');
41const paths = require('../config/paths');
42argv.push(
43 '--config',
44 JSON.stringify(
45 createJestConfig(
46 relativePath => path.resolve(__dirname, '..', relativePath),
47 path.resolve(paths.appSrc, '..'),
48 false
49 )
50 )
51);
52// @remove-on-eject-end
53jest.run(argv);