Skip to content

Commit

Permalink
fix: simplify promise finally action (#15199)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha authored Jul 21, 2024
1 parent 8e9950e commit 14d305b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions packages/jest-circus/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,13 @@ export const callAsyncCircusFn = (
// Otherwise this test is synchronous, and if it didn't throw it means
// it passed.
resolve();
})
.then(() => {
completed = true;
// If timeout is not cleared/unrefed the node process won't exit until
// it's resolved.
timeoutID.unref?.();
clearTimeout(timeoutID);
})
.catch(error => {
completed = true;
timeoutID.unref?.();
clearTimeout(timeoutID);
throw error;
});
}).finally(() => {
completed = true;
// If timeout is not cleared/unrefed the node process won't exit until
// it's resolved.
timeoutID.unref?.();
clearTimeout(timeoutID);
});
};

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

0 comments on commit 14d305b

Please sign in to comment.