From 37f6e4b66132ecd0766203d483b186e45230307e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 6 Jul 2024 23:47:28 +0100 Subject: [PATCH] HTML Reporter: Fix silent handling of early error Follows-up 4c09baf8462f4978, which introduced a secondary error during the handling of an early error. Early errors (i.e. before QUnit.begin renders the UI) have never been surfaced in the UI by QUnit, although I have an idea for how we could support that - TODO! --- src/reporters/HtmlReporter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/reporters/HtmlReporter.js b/src/reporters/HtmlReporter.js index 468862fba..05cac7b91 100644 --- a/src/reporters/HtmlReporter.js +++ b/src/reporters/HtmlReporter.js @@ -22,7 +22,7 @@ const DOM = { } }, // TODO: Use HTMLElement.classList. IE11+, except toggle(x,y), add(x,y), or remove(x,y). - // TODO: Verity that eslint-plugin-compat catches those exceptions. + // TODO: Verify that eslint-plugin-compat catches those exceptions. hasClass (elem, name) { return (' ' + elem.className + ' ').indexOf(' ' + name + ' ') >= 0; }, @@ -1046,9 +1046,13 @@ export default class HtmlReporter { } onError (error) { - const testItem = this.appendTest('global failure'); + const testItem = this.element && this.appendTest('global failure'); if (!testItem) { // HTML Reporter is probably disabled or not yet initialized. + // This kind of early error will be visible in the browser console + // and via window.onerror, but we can't show it in the UI. + // + // TODO: Consider stashing early error here and replay in UI during onRunStart. return; }