Skip to content

Commit

Permalink
RDY: feat(jest-cli): add forceExitAfterTestRun avg (Duplicated of PR #…
Browse files Browse the repository at this point in the history
…1847) (#1870)

* feat(jest-cli): add forceExit avg on cli

After run all tests that force exit when forceExit is true

#1456

* Fix typecheck & linter offences

* Improve null check expression

* Update index.js
  • Loading branch information
pastuxso authored and cpojer committed Oct 17, 2016
1 parent 8f634b3 commit 6fbeaa4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/jest-cli/src/cli/args.js
Expand Up @@ -261,6 +261,14 @@ const options = {
'Will run all tests affected by file changes in the last commit made.',
type: 'boolean',
},
forceExit: {
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
6 changes: 5 additions & 1 deletion packages/jest-cli/src/cli/index.js
Expand Up @@ -39,7 +39,11 @@ function run(argv?: Object, root?: Path) {
}

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

Expand Down
1 change: 1 addition & 0 deletions types/Config.js
Expand Up @@ -78,4 +78,5 @@ export type Config = DefaultConfig & {|
updateSnapshot: boolean,
usesBabelJest: boolean,
watchman: boolean,
forceExit: boolean,
|};

0 comments on commit 6fbeaa4

Please sign in to comment.