diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index f498d63c166c..42d39276331e 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -114,7 +114,7 @@ const readResultsAndExit = ( ) => { const code = !result || result.success ? 0 : globalConfig.testFailureExitCode; - process.on('exit', () => exit(code)); + process.on('exit', () => (process.exitCode = code)); if (globalConfig.forceExit) { exit(code); diff --git a/packages/jest-runtime/src/cli/index.js b/packages/jest-runtime/src/cli/index.js index 3c785116cd08..a936d5879b14 100644 --- a/packages/jest-runtime/src/cli/index.js +++ b/packages/jest-runtime/src/cli/index.js @@ -11,7 +11,6 @@ import type {Argv} from 'types/Argv'; import type {EnvironmentClass} from 'types/Environment'; import chalk from 'chalk'; -import exit from 'exit'; import os from 'os'; import path from 'path'; import yargs from 'yargs'; @@ -43,7 +42,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { if (argv.help) { yargs.showHelp(); - process.on('exit', () => exit(1)); + process.on('exit', () => (process.exitCode = 1)); return; } @@ -54,7 +53,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { if (!argv._.length) { console.log('Please provide a path to a script. (See --help for details)'); - process.on('exit', () => exit(1)); + process.on('exit', () => (process.exitCode = 1)); return; } @@ -93,6 +92,6 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { }) .catch(e => { console.error(chalk.red(e.stack || e)); - process.on('exit', () => exit(1)); + process.on('exit', () => (process.exitCode = 1)); }); }