From 0280825f1a672ba23d9fcbbc6470a4b29d343a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Wed, 1 Mar 2023 17:37:42 +0200 Subject: [PATCH] fix: console log not visible (#2943) Fixes #2943 --- packages/vitest/src/runtime/rpc.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)