···54545555 function resolve(result: unknown) {
5656 clearTimeout(timer)
5757+ // if test/hook took too long in microtask, setTimeout won't be triggered,
5858+ // but we still need to fail the test, see
5959+ // https://github.com/vitest-dev/vitest/issues/2920
6060+ if (now() - startTime >= timeout) {
6161+ reject_(new Error(makeTimeoutMsg(isHook, timeout)))
6262+ return
6363+ }
5764 resolve_(result)
5865 }
5966···6875 // the result is a thenable, we don't wrap this in Promise.resolve
6976 // to avoid creating new promises
7077 if (typeof result === 'object' && result != null && typeof result.then === 'function') {
7171- result.then(
7272- (result) => {
7373- // if sync test/hook took too long, setTimeout won't be triggered,
7474- // but we still need to fail the test, see
7575- // https://github.com/vitest-dev/vitest/issues/2920
7676- if (now() - startTime >= timeout) {
7777- reject(new Error(makeTimeoutMsg(isHook, timeout)))
7878- }
7979- else {
8080- resolve(result)
8181- }
8282- },
8383- reject,
8484- )
7878+ result.then(resolve, reject)
8579 }
8680 else {
8781 resolve(result)
···118118"Error: Test timed out in 20ms.
119119Error: Test timed out in 200ms.
120120Error: Test timed out in 100ms.
121121+Error: Hook timed out in 17ms.
121122Error: Test timed out in 15ms.
122122-Error: Test timed out in 10ms."
123123+Error: Test timed out in 10ms.
124124+Error: Hook timed out in 16ms."
123125`;
124126125127exports[`should fail unhandled.test.ts 1`] = `