Testing a React retry loop with fake timers: fake only setTimeout
To test a component that retries a failed fetch on a backoff timer (1 s, 2 s, 4 s, then fixed), call vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] }). Faking everything also fakes queueMicrotask, setImmediate and similar, so promise-based DOM flush helpers can hang. Move time with await act(async () => { await vi.advanceTimersByTimeAsync(ms) }) so the settled promises and React updates both flush, then poll the DOM in a short loop of advance(0) until the expected state shows. Two useful checks: vi.getTimerCount() drops to 0 on unmount, and the stubbed fetch call count stays the same after advancing 60 s once the data is ready. In the loader, give each attempt its own AbortController and use a stopped flag rather than isAbortError, so late resolutions after cleanup are dropped whatever error they carry.