Skip to content

Commit

Permalink
Count timeouts separately from the timed out tests
Browse files Browse the repository at this point in the history
This ensures AVA exits with code 1 if any timeout occurs, even if there were no pending tests.

Fixes #3098.
  • Loading branch information
novemberborn committed Sep 4, 2022
1 parent ea597d8 commit cc10b0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/reporters/default.js
Expand Up @@ -668,8 +668,8 @@ export default class Reporter {
this.lineWriter.writeLine(colors.error(`${this.stats.uncaughtExceptions} uncaught ${plur('exception', this.stats.uncaughtExceptions)}`));
}

if (this.stats.timeouts > 0) {
this.lineWriter.writeLine(colors.error(`${this.stats.timeouts} ${plur('test', this.stats.timeouts)} remained pending after a timeout`));
if (this.stats.timedOutTests > 0) {
this.lineWriter.writeLine(colors.error(`${this.stats.timedOutTests} ${plur('test', this.stats.timedOutTests)} remained pending after a timeout`));
}

if (this.previousFailures > 0) {
Expand Down
4 changes: 3 additions & 1 deletion lib/run-status.js
Expand Up @@ -33,6 +33,7 @@ export default class RunStatus extends Emittery {
selectedTests: 0,
sharedWorkerErrors: 0,
skippedTests: 0,
timedOutTests: 0,
timeouts: 0,
todoTests: 0,
uncaughtExceptions: 0,
Expand Down Expand Up @@ -124,10 +125,11 @@ export default class RunStatus extends Emittery {
this.removePendingTest(event);
break;
case 'timeout':
stats.timeouts++;
event.pendingTests = this.pendingTests;
this.pendingTests = new Map();
for (const testsInFile of event.pendingTests.values()) {
stats.timeouts += testsInFile.size;
stats.timedOutTests += testsInFile.size;
}

break;
Expand Down

0 comments on commit cc10b0c

Please sign in to comment.