HTML reporter: cache configuration throughout each run

This commit is contained in:
Steve Gravrock
2025-10-07 18:55:18 -07:00
parent 1f521f2a7f
commit 10ad40357a
2 changed files with 12 additions and 20 deletions

View File

@@ -126,6 +126,7 @@ jasmineRequire.HtmlReporter = function(j$) {
#urlBuilder; #urlBuilder;
#filterSpecs; #filterSpecs;
#stateBuilder; #stateBuilder;
#config;
#htmlReporterMain; #htmlReporterMain;
// Sub-views // Sub-views
@@ -157,13 +158,12 @@ jasmineRequire.HtmlReporter = function(j$) {
*/ */
initialize() { initialize() {
this.#clearPrior(); this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {};
this.#stateBuilder = new ResultsStateBuilder(); this.#stateBuilder = new ResultsStateBuilder();
this.#alerts = new AlertsView(this.#domContext, this.#urlBuilder); this.#alerts = new AlertsView(this.#domContext, this.#urlBuilder);
this.#symbols = new SymbolsView( this.#symbols = new SymbolsView(this.#domContext);
this.#domContext,
this.#config.bind(this)
);
this.#banner = new Banner(this.#domContext, this.#navigateWithNewParam); this.#banner = new Banner(this.#domContext, this.#navigateWithNewParam);
this.#failures = new FailuresView(this.#domContext, this.#urlBuilder); this.#failures = new FailuresView(this.#domContext, this.#urlBuilder);
this.#htmlReporterMain = this.#domContext.create( this.#htmlReporterMain = this.#domContext.create(
@@ -197,7 +197,7 @@ jasmineRequire.HtmlReporter = function(j$) {
specDone(result) { specDone(result) {
this.#stateBuilder.specDone(result); this.#stateBuilder.specDone(result);
this.#symbols.append(result, this.#config()); this.#symbols.append(result, this.#config);
if (noExpectations(result)) { if (noExpectations(result)) {
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations."; const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
@@ -218,7 +218,7 @@ jasmineRequire.HtmlReporter = function(j$) {
jasmineDone(doneResult) { jasmineDone(doneResult) {
this.#stateBuilder.jasmineDone(doneResult); this.#stateBuilder.jasmineDone(doneResult);
this.#alerts.addDuration(doneResult.totalTime); this.#alerts.addDuration(doneResult.totalTime);
this.#banner.showOptionsMenu(this.#config()); this.#banner.showOptionsMenu(this.#config);
if ( if (
this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined
@@ -261,10 +261,6 @@ jasmineRequire.HtmlReporter = function(j$) {
} }
} }
#config() {
return (this.#env && this.#env.configuration()) || {};
}
#find(selector) { #find(selector) {
return this.#getContainer().querySelector( return this.#getContainer().querySelector(
'.jasmine_html-reporter ' + selector '.jasmine_html-reporter ' + selector

View File

@@ -91,6 +91,7 @@ jasmineRequire.HtmlReporter = function(j$) {
#urlBuilder; #urlBuilder;
#filterSpecs; #filterSpecs;
#stateBuilder; #stateBuilder;
#config;
#htmlReporterMain; #htmlReporterMain;
// Sub-views // Sub-views
@@ -122,13 +123,12 @@ jasmineRequire.HtmlReporter = function(j$) {
*/ */
initialize() { initialize() {
this.#clearPrior(); this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {};
this.#stateBuilder = new ResultsStateBuilder(); this.#stateBuilder = new ResultsStateBuilder();
this.#alerts = new AlertsView(this.#domContext, this.#urlBuilder); this.#alerts = new AlertsView(this.#domContext, this.#urlBuilder);
this.#symbols = new SymbolsView( this.#symbols = new SymbolsView(this.#domContext);
this.#domContext,
this.#config.bind(this)
);
this.#banner = new Banner(this.#domContext, this.#navigateWithNewParam); this.#banner = new Banner(this.#domContext, this.#navigateWithNewParam);
this.#failures = new FailuresView(this.#domContext, this.#urlBuilder); this.#failures = new FailuresView(this.#domContext, this.#urlBuilder);
this.#htmlReporterMain = this.#domContext.create( this.#htmlReporterMain = this.#domContext.create(
@@ -162,7 +162,7 @@ jasmineRequire.HtmlReporter = function(j$) {
specDone(result) { specDone(result) {
this.#stateBuilder.specDone(result); this.#stateBuilder.specDone(result);
this.#symbols.append(result, this.#config()); this.#symbols.append(result, this.#config);
if (noExpectations(result)) { if (noExpectations(result)) {
const noSpecMsg = "Spec '" + result.fullName + "' has no expectations."; const noSpecMsg = "Spec '" + result.fullName + "' has no expectations.";
@@ -183,7 +183,7 @@ jasmineRequire.HtmlReporter = function(j$) {
jasmineDone(doneResult) { jasmineDone(doneResult) {
this.#stateBuilder.jasmineDone(doneResult); this.#stateBuilder.jasmineDone(doneResult);
this.#alerts.addDuration(doneResult.totalTime); this.#alerts.addDuration(doneResult.totalTime);
this.#banner.showOptionsMenu(this.#config()); this.#banner.showOptionsMenu(this.#config);
if ( if (
this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined this.#stateBuilder.specsExecuted < this.#stateBuilder.totalSpecsDefined
@@ -226,10 +226,6 @@ jasmineRequire.HtmlReporter = function(j$) {
} }
} }
#config() {
return (this.#env && this.#env.configuration()) || {};
}
#find(selector) { #find(selector) {
return this.#getContainer().querySelector( return this.#getContainer().querySelector(
'.jasmine_html-reporter ' + selector '.jasmine_html-reporter ' + selector