Skip to content

Commit

Permalink
Fix test interruption (jestjs#2491)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeliog authored and cpojer committed Jan 14, 2017
1 parent e4e3924 commit 47f3944
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/jest-cli/src/TestWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ module.exports = (
{config, path, rawModuleMap}: WorkerData,
callback: WorkerCallback,
) => {
let parentExited = false;

process.on('disconnect', () => parentExited = true);

try {
runTest(path, config, getResolver(config, rawModuleMap))
.then(
result => callback(null, result),
error => callback(formatError(error)),
result => !parentExited && callback(null, result),
error => !parentExited && callback(formatError(error)),
);
} catch (error) {
callback(formatError(error));
Expand Down

0 comments on commit 47f3944

Please sign in to comment.