Deprecate spec/suite orders that interleave suites

This commit is contained in:
Steve Gravrock
2025-08-13 19:02:36 -07:00
parent 8e3ec25f6d
commit 2299c85751
4 changed files with 42 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().TreeProcessor = function() {
getJasmineRequireObj().TreeProcessor = function(j$) {
const defaultMin = Infinity;
const defaultMax = 1 - Infinity;
@@ -128,14 +128,17 @@ getJasmineRequireObj().TreeProcessor = function() {
segmentChildren(node, orderedChildren, this.#stats, executableIndex);
if (
!node.canBeReentered() &&
this.#stats[node.id].segments.length > 1
) {
this.#stats = { valid: false };
throw new Error(
'Invalid order: would cause a beforeAll or afterAll to be run multiple times'
);
if (this.#stats[node.id].segments.length > 1) {
if (node.canBeReentered()) {
j$.getEnv().deprecated(
'The specified spec/suite order splits up a suite, running unrelated specs in the middle of it. This will become an error in a future release.'
);
} else {
this.#stats = { valid: false };
throw new Error(
'Invalid order: would cause a beforeAll or afterAll to be run multiple times'
);
}
}
}
}

View File

@@ -83,7 +83,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
j$.Suite = jRequire.Suite(j$);
j$.SuiteBuilder = jRequire.SuiteBuilder(j$);
j$.Timer = jRequire.Timer();
j$.TreeProcessor = jRequire.TreeProcessor();
j$.TreeProcessor = jRequire.TreeProcessor(j$);
j$.version = jRequire.version();
j$.Order = jRequire.Order();
j$.DiffBuilder = jRequire.DiffBuilder(j$);