HtmlReporterV2: show correct progress when running a subset of specs

This commit is contained in:
Steve Gravrock
2025-11-26 20:51:02 -08:00
parent d7b1456584
commit b559faec2a
8 changed files with 150 additions and 33 deletions

View File

@@ -1102,7 +1102,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
jasmineStarted(options) {
this.#stateBuilder.jasmineStarted(options);
this.#progress.start(options.totalSpecsDefined);
this.#progress.start(
options.totalSpecsDefined - options.numExcludedSpecs
);
}
suiteStarted(result) {
@@ -1218,7 +1220,9 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
}
specDone(result) {
this.rootEl.value = this.rootEl.value + 1;
if (result.status !== 'excluded') {
this.rootEl.value = this.rootEl.value + 1;
}
if (result.status === 'failed') {
this.rootEl.classList.add('failed');

View File

@@ -9862,7 +9862,8 @@ getJasmineRequireObj().Runner = function(j$) {
/**
* Information passed to the {@link Reporter#jasmineStarted} event.
* @typedef JasmineStartedInfo
* @property {Int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
* @property {int} totalSpecsDefined - The total number of specs defined in this suite. Note that this property is not present when Jasmine is run in parallel mode.
* @property {int} numExcludedSpecs - The number of specs that will be excluded from execution. Note that this property is not present when Jasmine is run in parallel mode.
* @property {Order} order - Information about the ordering (random or not) of this execution of the suite. Note that this property is not present when Jasmine is run in parallel mode.
* @property {Boolean} parallel - Whether Jasmine is being run in parallel mode.
* @since 2.0.0
@@ -9871,6 +9872,7 @@ getJasmineRequireObj().Runner = function(j$) {
// In parallel mode, the jasmineStarted event is separately dispatched
// by jasmine-npm. This event only reaches reporters in non-parallel.
totalSpecsDefined,
numExcludedSpecs: this.#executionTree.numExcludedSpecs(),
order: orderForReporting(order),
parallel: false
});
@@ -11977,6 +11979,23 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
const nodeStats = this.#stats[node.id];
return node.children ? !nodeStats.willExecute : nodeStats.excluded;
}
numExcludedSpecs(node) {
if (!node) {
return this.numExcludedSpecs(this.topSuite);
} else if (node.children) {
let result = 0;
for (const child of node.children) {
result += this.numExcludedSpecs(child);
}
return result;
} else {
const nodeStats = this.#stats[node.id];
return nodeStats.willExecute ? 0 : 1;
}
}
}
function segmentChildren(node, orderedChildren, stats, executableIndex) {