Skip to content

Commit

Permalink
warn if a worker had to be force exited
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Mar 25, 2019
1 parent 0a51a2d commit e58fd9a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/jest-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import {Config} from '@jest/types';
import {SerializableError} from '@jest/test-result';
import chalk from 'chalk';
import exit from 'exit';
import throat from 'throat';
import Worker from 'jest-worker';
Expand Down Expand Up @@ -185,7 +186,18 @@ class TestRunner {
),
);

const cleanup = () => worker.end();
const cleanup = async () => {
const {forceExited} = await worker.end();
if (forceExited) {
console.log(
chalk.yellow(
'A worker process has failed to exit gracefully and has been force exited. ' +
'This is likely caused by tests leaking due to improper teardown. ' +
'Try running with --runInBand --detectOpenHandles to find leaks.',
),
);
}
};
return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup);
}
}
Expand Down

0 comments on commit e58fd9a

Please sign in to comment.