Skip to content

Commit

Permalink
HTML Reporter: Fix silent handling of early error
Browse files Browse the repository at this point in the history
Follows-up 4c09baf, 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!
  • Loading branch information
Krinkle committed Jul 6, 2024
1 parent 0c0edb7 commit 37f6e4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/reporters/HtmlReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 37f6e4b

Please sign in to comment.