From 5f2f366bcf3f30e7ec4ad4f1f61f27b8d9b4b0bf Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 22 Nov 2024 15:54:03 -0500 Subject: [PATCH] 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. --- lib/internal/test_runner/runner.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js index 0ba40d7ba7f71f..43a62b5b4307e4 100644 --- a/lib/internal/test_runner/runner.js +++ b/lib/internal/test_runner/runner.js @@ -17,7 +17,6 @@ const { ArrayPrototypeSort, ObjectAssign, PromisePrototypeThen, - PromiseResolve, PromiseWithResolvers, SafeMap, SafePromiseAll, @@ -801,9 +800,17 @@ function run(options = kEmptyObject) { } } - const setupPromise = PromiseResolve(setup?.(root.reporter)); - PromisePrototypeThen(PromisePrototypeThen(PromisePrototypeThen(setupPromise, runFiles), postRun), teardown); + const runChain = async () => { + if (typeof setup === 'function') { + await setup(root.reporter); + } + + await runFiles(); + postRun?.(); + teardown?.(); + }; + runChain(); return root.reporter; }