Skip to content

Commit 14d305b

Browse files
authored
fix: simplify promise finally action (#15199)
1 parent 8e9950e commit 14d305b

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/jest-circus/src/utils.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,13 @@ export const callAsyncCircusFn = (
301301
// Otherwise this test is synchronous, and if it didn't throw it means
302302
// it passed.
303303
resolve();
304-
})
305-
.then(() => {
306-
completed = true;
307-
// If timeout is not cleared/unrefed the node process won't exit until
308-
// it's resolved.
309-
timeoutID.unref?.();
310-
clearTimeout(timeoutID);
311-
})
312-
.catch(error => {
313-
completed = true;
314-
timeoutID.unref?.();
315-
clearTimeout(timeoutID);
316-
throw error;
317-
});
304+
}).finally(() => {
305+
completed = true;
306+
// If timeout is not cleared/unrefed the node process won't exit until
307+
// it's resolved.
308+
timeoutID.unref?.();
309+
clearTimeout(timeoutID);
310+
});
318311
};
319312

320313
export const getTestDuration = (test: Circus.TestEntry): number | null => {

0 commit comments

Comments
 (0)