Skip to content

Commit

Permalink
feat: different message for negative times
Browse files Browse the repository at this point in the history
This shouldn't really ever be hit; at least, for healthy tests?

It will probably never be seen by users, as it should be masked
by the rest of the timeout mechanism.
  • Loading branch information
FauxFaux committed Dec 16, 2020
1 parent 3086c70 commit 347f598
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/jest-circus/src/deadlineTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export function deadline(): number {
}

export async function withinDeadline<T>(promise: Promise<T>): Promise<T> {
return timeout(promise, deadline() - Date.now());
const ms = deadline() - Date.now();
if (ms <= 0) {
throw removeUsFromStack(new Error('deadline already exceeded'));
}
return timeout(promise, ms);
}

function isUs(line: string): boolean {
Expand Down

0 comments on commit 347f598

Please sign in to comment.