Skip to content

Commit 7c3a4d4

Browse files
cjihrigaduh95
authored andcommitted
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. PR-URL: #55958 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 95e8c4e commit 7c3a4d4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/internal/test_runner/runner.js

+10-3
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,17 @@ 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+
postRun?.();
810+
teardown?.();
811+
};
806812

813+
runChain();
807814
return root.reporter;
808815
}
809816

0 commit comments

Comments
 (0)