From 662ac5548fe030a21288adce0c2e764c4a078d56 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 1 Aug 2020 20:57:51 +0200 Subject: [PATCH] Log suite start failures in the test runner --- test/unit/testreporter.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/unit/testreporter.js b/test/unit/testreporter.js index ab517d6f7..41502d6d3 100644 --- a/test/unit/testreporter.js +++ b/test/unit/testreporter.js @@ -51,7 +51,21 @@ var TestReporter = function (browser) { sendInfo("Started tests for " + browser + "."); }; - this.suiteStarted = function (result) {}; + this.suiteStarted = function (result) { + // Normally suite starts don't have to be reported because the individual + // specs inside them are reported, but it can happen that the suite cannot + // start, for instance due to an uncaught exception in `beforeEach`. This + // is problematic because the specs inside the suite will never be found + // and run, so if we don't report the suite start failure here it would be + // ignored silently, leading to passing tests even though some did not run. + if (result.failedExpectations.length > 0) { + let failedMessages = ""; + for (const item of result.failedExpectations) { + failedMessages += `${item.message} `; + } + sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages); + } + }; this.specStarted = function (result) {};