From 98595dae58209a9062d0238c7a3dd7078a9962d1 Mon Sep 17 00:00:00 2001 From: tymfear Date: Thu, 31 Dec 2020 16:09:34 +0200 Subject: [PATCH] Fix timeout reporting in TAP reporter Fixes #2612 Co-authored-by: Daudov, Tymur --- lib/reporters/tap.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/reporters/tap.js b/lib/reporters/tap.js index b7bda3067..d3d4a4603 100644 --- a/lib/reporters/tap.js +++ b/lib/reporters/tap.js @@ -131,6 +131,16 @@ class TapReporter { } } + writeTimeout(evt) { + const err = new Error(`Exited because no new tests completed within the last ${evt.period}ms of inactivity`); + + for (const [testFile, tests] of evt.pendingTests) { + for (const title of tests) { + this.writeTest({testFile, title, err}, {passed: false, todo: false, skip: false}); + } + } + } + consumeStateChange(evt) { // eslint-disable-line complexity const fileStats = this.stats && evt.testFile ? this.stats.byFile.get(evt.testFile) : null; @@ -172,7 +182,7 @@ class TapReporter { this.writeTest(evt, {passed: true, todo: false, skip: false}); break; case 'timeout': - this.writeCrash(evt, `Exited because no new tests completed within the last ${evt.period}ms of inactivity`); + this.writeTimeout(evt); break; case 'uncaught-exception': this.writeCrash(evt);