HtmlReporterV2: Show details of failures as soon as they occur

This commit is contained in:
Steve Gravrock
2025-10-14 21:49:33 -07:00
parent 4663280528
commit 10bc655622
3 changed files with 26 additions and 4 deletions

View File

@@ -782,10 +782,12 @@ jasmineRequire.FailuresView = function(j$) {
class FailuresView {
#urlBuilder;
#failureEls;
#showing;
constructor(urlBuilder) {
this.#urlBuilder = urlBuilder;
this.#failureEls = [];
this.#showing = false;
this.rootEl = createDom(
'div',
{ className: 'jasmine-results' },
@@ -794,8 +796,14 @@ jasmineRequire.FailuresView = function(j$) {
}
append(result, parent) {
// TODO: Figure out why the reuslt is wrong if we build the DOM node later
this.#failureEls.push(this.#makeFailureEl(result, parent));
// TODO: Figure out why the result is wrong if we build the DOM node later
const el = this.#makeFailureEl(result, parent);
if (this.#showing) {
this.rootEl.querySelector('.jasmine-failures').appendChild(el);
} else {
this.#failureEls.push(el);
}
}
show() {
@@ -804,6 +812,8 @@ jasmineRequire.FailuresView = function(j$) {
for (const el of this.#failureEls) {
failureNode.appendChild(el);
}
this.#showing = true;
}
#makeFailureEl(result, parent) {
@@ -1057,6 +1067,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
this.#failures.rootEl
);
this.#container.appendChild(this.#htmlReporterMain);
this.#failures.show();
}
jasmineStarted(options) {

View File

@@ -6,10 +6,12 @@ jasmineRequire.FailuresView = function(j$) {
class FailuresView {
#urlBuilder;
#failureEls;
#showing;
constructor(urlBuilder) {
this.#urlBuilder = urlBuilder;
this.#failureEls = [];
this.#showing = false;
this.rootEl = createDom(
'div',
{ className: 'jasmine-results' },
@@ -18,8 +20,14 @@ jasmineRequire.FailuresView = function(j$) {
}
append(result, parent) {
// TODO: Figure out why the reuslt is wrong if we build the DOM node later
this.#failureEls.push(this.#makeFailureEl(result, parent));
// TODO: Figure out why the result is wrong if we build the DOM node later
const el = this.#makeFailureEl(result, parent);
if (this.#showing) {
this.rootEl.querySelector('.jasmine-failures').appendChild(el);
} else {
this.#failureEls.push(el);
}
}
show() {
@@ -28,6 +36,8 @@ jasmineRequire.FailuresView = function(j$) {
for (const el of this.#failureEls) {
failureNode.appendChild(el);
}
this.#showing = true;
}
#makeFailureEl(result, parent) {

View File

@@ -71,6 +71,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
this.#failures.rootEl
);
this.#container.appendChild(this.#htmlReporterMain);
this.#failures.show();
}
jasmineStarted(options) {