Don't expose Order instances to reporters

This commit is contained in:
Steve Gravrock
2025-09-14 09:44:58 -07:00
parent 27297de3b8
commit 6ab83e25d1
4 changed files with 43 additions and 25 deletions

View File

@@ -106,13 +106,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,
/**
* Information about the ordering (random or not) of this execution of the suite.
* @typedef Order
* @property {boolean} random - Whether the suite is running in random order
* @property {string} seed - The random seed
*/
order: order,
order: orderForReporting(order),
parallel: false
});
@@ -164,7 +158,7 @@ getJasmineRequireObj().Runner = function(j$) {
totalTime: jasmineTimer.elapsed(),
incompleteReason: incompleteReason,
incompleteCode: incompleteCode,
order: order,
order: orderForReporting(order),
failedExpectations: this.#topSuite.result.failedExpectations,
deprecationWarnings: this.#topSuite.result.deprecationWarnings
};
@@ -174,5 +168,21 @@ getJasmineRequireObj().Runner = function(j$) {
}
}
/**
* Information about the ordering (random or not) of this execution of the suite.
* @typedef Order
* @property {boolean} random - Whether the suite is running in random order
* @property {string} seed - The random seed
*/
function orderForReporting(order) {
// Don't expose the actual Order object to reporters. That class is private
// and instances are not cloneable.
if (order.random) {
return { random: true, seed: order.seed };
} else {
return { random: false };
}
}
return Runner;
};