From 538b1005efa0e0a2335a36e91e94f9c963bf13c4 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 22 Feb 2026 02:18:47 +0900 Subject: [PATCH] fix(test): flush fake timer microtasks in todo continuation tests --- .../todo-continuation-enforcer.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hooks/todo-continuation-enforcer/todo-continuation-enforcer.test.ts b/src/hooks/todo-continuation-enforcer/todo-continuation-enforcer.test.ts index defe8c8b2..19d2222f6 100644 --- a/src/hooks/todo-continuation-enforcer/todo-continuation-enforcer.test.ts +++ b/src/hooks/todo-continuation-enforcer/todo-continuation-enforcer.test.ts @@ -41,6 +41,12 @@ function createFakeTimers(): FakeTimers { return delay < 0 ? 0 : delay } + const flushMicrotasks = async (iterations: number = 5) => { + for (let index = 0; index < iterations; index++) { + await Promise.resolve() + } + } + const schedule = (callback: TimerCallback, delay: number | undefined, interval: number | null, args: any[]) => { const id = nextId++ timers.set(id, { @@ -130,16 +136,16 @@ function createFakeTimers(): FakeTimers { cleared.delete(next.id) } - await Promise.resolve() + await flushMicrotasks() } timerNow = target - await Promise.resolve() + await flushMicrotasks() } const advanceClockBy = async (ms: number) => { const clamped = Math.max(0, ms) clockNow += clamped - await Promise.resolve() + await flushMicrotasks() } const restore = () => {