Skip to content

Commit 1b298a1

Browse files
committed
test_runner: refactor Promise chain in run()
This commit refactors the chain of functions in run() to use an async function instead of creating an awkward primordial-based Promise chain.
1 parent 06085bd commit 1b298a1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/internal/test_runner/runner.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const {
1717
ArrayPrototypeSort,
1818
ObjectAssign,
1919
PromisePrototypeThen,
20-
PromiseResolve,
2120
PromiseWithResolvers,
2221
SafeMap,
2322
SafePromiseAll,
@@ -801,9 +800,23 @@ function run(options = kEmptyObject) {
801800
}
802801
}
803802

804-
const setupPromise = PromiseResolve(setup?.(root.reporter));
805-
PromisePrototypeThen(PromisePrototypeThen(PromisePrototypeThen(setupPromise, runFiles), postRun), teardown);
803+
const runChain = async () => {
804+
if (typeof setup === 'function') {
805+
await setup(root.reporter);
806+
}
807+
808+
await runFiles();
809+
810+
if (typeof postRun === 'function') {
811+
postRun();
812+
}
813+
814+
if (typeof teardown === 'function') {
815+
teardown();
816+
}
817+
};
806818

819+
runChain();
807820
return root.reporter;
808821
}
809822

0 commit comments

Comments
 (0)