1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
7 // Do this as the first thing so that any code reading it knows the right env.
8 process.env.BABEL_ENV = 'test';
9 process.env.NODE_ENV = 'test';
10 process.env.PUBLIC_URL = '';
12 // Makes the script crash on unhandled rejections instead of silently
13 // ignoring them. In the future, promise rejections that are not handled will
14 // terminate the Node.js process with a non-zero exit code.
15 process.on('unhandledRejection', err => {
19 // Ensure environment variables are read.
20 require('../config/env');
22 const jest = require('jest');
23 const execSync = require('child_process').execSync;
24 let argv = process.argv.slice(2);
26 function isInGitRepository() {
28 execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
35 function isInMercurialRepository() {
37 execSync('hg --cwd . root', { stdio: 'ignore' });
44 // Watch unless on CI or explicitly running all tests
47 argv.indexOf('--watchAll') === -1 &&
48 argv.indexOf('--watchAll=false') === -1
50 // https://github.com/facebook/create-react-app/issues/5210
51 const hasSourceControl = isInGitRepository() || isInMercurialRepository();
52 argv.push(hasSourceControl ? '--watch' : '--watchAll');