You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
waitFor not working when vi.useFakeTimers is used #565
When vi.useFakeTimers is used in a test, waitFor does not longer run change detection.
it('works',async()=>{vi.useFakeTimers()constview=awaitrender(MyComponent)view.detectChanges()expect(screen.getByRole('input').toHaveAccessibleDescription(/something/))})it('does not work',async()=>{vi.useFakeTimers()awaitrender(MyComponent)awaitwaitFor(()=>expect(screen.getByRole('input').toHaveAccessibleDescription(/something/)))})
It only happens when using Vitest, not when using Jest. (in fact, globalThis.jest = vi in the setup script suffices as workaround for some reason)
@jonaskuske could you see any problems if we change the timeout to your suggested implementation? If not, I think it's a good suggestion, and you can create a PR with this change.
Activity
ThiloAschebrock commentedon Mar 4, 2026
A workaround is to configure the fake timers to advance time via
vi.userFakeTimers({ shouldAdvanceTime: true }).timdeschryver commentedon Mar 8, 2026
@jonaskuske could you see any problems if we change the timeout to your suggested implementation? If not, I think it's a good suggestion, and you can create a PR with this change.
This should also be resolved in #570.
fix: replace setTimeout with queueMicrotask to prevent deadlock
jonaskuske commentedon Mar 11, 2026
I don't think so, PR is out :)
(no guarantee though,
Promise.resolve()/queueMicrotask()will make this a microtask rather than a task, so the timing can be a bit different)fix: replace setTimeout with queueMicrotask to prevent Vitest deadlock (
github-actions commentedon Mar 11, 2026
🎉 This issue has been resolved in version 19.1.1 🎉
The release is available on:
Your semantic-release bot 📦🚀