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) {};