diff --git a/packages/vitest/src/runtime/rpc.ts b/packages/vitest/src/runtime/rpc.ts index b845e13d5b43..19b10b3ab5db 100644 --- a/packages/vitest/src/runtime/rpc.ts +++ b/packages/vitest/src/runtime/rpc.ts @@ -41,7 +41,11 @@ function withSafeTimers(fn: () => void) { const promises = new Set>() -export const rpcDone = () => { +export const rpcDone = async () => { + // Run possible setTimeouts, e.g. the onces used by ConsoleLogSpy + const { setTimeout } = getSafeTimers() + await new Promise(resolve => setTimeout(resolve)) + if (!promises.size) return const awaitable = Array.from(promises)