Skip to content

Commit

Permalink
feat(jest-cli): add forceExitAfterTestRun avg
Browse files Browse the repository at this point in the history
After run all tests that force exit when forceExitAfterTestRun is true

jestjs#1456
  • Loading branch information
yutin1987 committed Oct 3, 2016
1 parent e4a50a4 commit 3f2710f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/jest-cli/src/cli/args.js
Expand Up @@ -261,6 +261,13 @@ const options = {
'Will run all tests affected by file changes in the last commit made.',
type: 'boolean',
},
forceExitAfterTestRun: {
default: false,
description:
'Force Jest to exit after all tests have completed running. ' +
'This is useful when resources set up by test code cannot be adequately cleaned up.',
type: 'boolean',
},
};

module.exports = {
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-cli/src/cli/index.js
Expand Up @@ -39,7 +39,10 @@ function run(argv?: Object, root?: Path) {
}

getJest(root).runCLI(argv, root, result => {
process.on('exit', () => process.exit(!result || result.success ? 0 : 1));
const success = !result || result.success;
process.on('exit', () => process.exit(success ? 0 : 1));

if (argv.forceExitAfterTestRun === true) process.exit(success ? 0 : 1);
});
}

Expand Down

0 comments on commit 3f2710f

Please sign in to comment.