Skip to content

Commit

Permalink
Ensure AVA exits with code 1 after an unexpected process.exit() in a …
Browse files Browse the repository at this point in the history
…test worker

It prints the error, so it should fail as such.
  • Loading branch information
novemberborn committed Jan 11, 2024
1 parent 35f6c86 commit cc8b839
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/run-status.js
Expand Up @@ -38,6 +38,7 @@ export default class RunStatus extends Emittery {
timeouts: 0,
todoTests: 0,
uncaughtExceptions: 0,
unexpectedProcessExits: 0,
unhandledRejections: 0,
};
}
Expand All @@ -56,6 +57,7 @@ export default class RunStatus extends Emittery {
skippedTests: 0,
todoTests: 0,
uncaughtExceptions: 0,
unexpectedProcessExits: 0,
unhandledRejections: 0,
...stats,
});
Expand Down Expand Up @@ -167,6 +169,8 @@ export default class RunStatus extends Emittery {
}

case 'process-exit': {
stats.unexpectedProcessExits++;
fileStats.unexpectedProcessExits++;
event.pendingTests = this.pendingTests;
event.pendingTestsLogs = this.pendingTestsLogs;
this.pendingTests = new Map();
Expand Down Expand Up @@ -237,6 +241,7 @@ export default class RunStatus extends Emittery {
|| this.stats.sharedWorkerErrors > 0
|| this.stats.timeouts > 0
|| this.stats.uncaughtExceptions > 0
|| this.stats.unexpectedProcessExits > 0
|| this.stats.unhandledRejections > 0
) {
return 1;
Expand Down

0 comments on commit cc8b839

Please sign in to comment.