◐ Shell
clean mode source ↗

test_runner: refactor Promise chain in run() · nodejs/node@fb98fa4

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,

@@ -798,9 +797,17 @@ function run(options = kEmptyObject) {

798797

}

799798

}

800799
801-

const setupPromise = PromiseResolve(setup?.(root.reporter));

802-

PromisePrototypeThen(PromisePrototypeThen(PromisePrototypeThen(setupPromise, runFiles), postRun), teardown);

800+

const runChain = async () => {

801+

if (typeof setup === 'function') {

802+

await setup(root.reporter);

803+

}

804+
805+

await runFiles();

806+

postRun?.();

807+

teardown?.();

808+

};

803809
810+

runChain();

804811

return root.reporter;

805812

}

806813