Convert some TreeRunner internals to promises

This commit is contained in:
Steve Gravrock
2025-08-21 07:58:28 -07:00
parent 164a393932
commit 3780fe0b35
3 changed files with 14 additions and 12 deletions
+6 -6
View File
@@ -11584,7 +11584,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
this.#reportDispatcher.specStarted(spec.result).then(next); this.#reportDispatcher.specStarted(spec.result).then(next);
}, },
(result, next) => { (result, next) => {
this.#specComplete(spec, result, next); this.#specComplete(spec).then(next);
}, },
done, done,
this.#executionTree.isExcluded(spec), this.#executionTree.isExcluded(spec),
@@ -11663,20 +11663,20 @@ getJasmineRequireObj().TreeRunner = function(j$) {
this.#reportDispatcher.suiteDone(result).then(next); this.#reportDispatcher.suiteDone(result).then(next);
} }
#specComplete(spec, result, next) { async #specComplete(spec) {
this.#runableResources.clearForRunable(spec.id); this.#runableResources.clearForRunable(spec.id);
this.#currentRunableTracker.setCurrentSpec(null); this.#currentRunableTracker.setCurrentSpec(null);
if (result.status === 'failed') { if (spec.result.status === 'failed') {
this.#hasFailures = true; this.#hasFailures = true;
} }
this.#reportSpecDone(spec, result, next); await this.#reportSpecDone(spec);
} }
#reportSpecDone(spec, result, next) { async #reportSpecDone(spec) {
spec.reportedDone = true; spec.reportedDone = true;
this.#reportDispatcher.specDone(result).then(next); await this.#reportDispatcher.specDone(spec.result);
} }
#addBeforeAndAfterAlls(suite, wrappedChildren) { #addBeforeAndAfterAlls(suite, wrappedChildren) {
+2
View File
@@ -112,6 +112,8 @@ describe('TreeRunner', function() {
expect(spec.result.duration).toEqual('the elapsed time'); expect(spec.result.duration).toEqual('the elapsed time');
expect(spec.reportedDone).toEqual(true); expect(spec.reportedDone).toEqual(true);
await Promise.resolve(); await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
expect(reportDispatcher.specDone).toHaveBeenCalledBefore(next); expect(reportDispatcher.specDone).toHaveBeenCalledBefore(next);
await expectAsync(promise).toBePending(); await expectAsync(promise).toBePending();
}); });
+6 -6
View File
@@ -75,7 +75,7 @@ getJasmineRequireObj().TreeRunner = function(j$) {
this.#reportDispatcher.specStarted(spec.result).then(next); this.#reportDispatcher.specStarted(spec.result).then(next);
}, },
(result, next) => { (result, next) => {
this.#specComplete(spec, result, next); this.#specComplete(spec).then(next);
}, },
done, done,
this.#executionTree.isExcluded(spec), this.#executionTree.isExcluded(spec),
@@ -154,20 +154,20 @@ getJasmineRequireObj().TreeRunner = function(j$) {
this.#reportDispatcher.suiteDone(result).then(next); this.#reportDispatcher.suiteDone(result).then(next);
} }
#specComplete(spec, result, next) { async #specComplete(spec) {
this.#runableResources.clearForRunable(spec.id); this.#runableResources.clearForRunable(spec.id);
this.#currentRunableTracker.setCurrentSpec(null); this.#currentRunableTracker.setCurrentSpec(null);
if (result.status === 'failed') { if (spec.result.status === 'failed') {
this.#hasFailures = true; this.#hasFailures = true;
} }
this.#reportSpecDone(spec, result, next); await this.#reportSpecDone(spec);
} }
#reportSpecDone(spec, result, next) { async #reportSpecDone(spec) {
spec.reportedDone = true; spec.reportedDone = true;
this.#reportDispatcher.specDone(result).then(next); await this.#reportDispatcher.specDone(spec.result);
} }
#addBeforeAndAfterAlls(suite, wrappedChildren) { #addBeforeAndAfterAlls(suite, wrappedChildren) {