Unsure how to utilize vi.advanceTimers with recursion #5675
Unanswered
CodyBontecou
asked this question in
Q&A
Replies: 1 comment 6 replies
-
Here's a reproduction: https://stackblitz.com/edit/vitest-dev-vitest-6xoabt?file=test%2Ftimeout.test.ts |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm attempting to test this function. I'm not entirely sure how to set this up using vitest.
Here's the function I'm attempting to test:
And here's my test, which passes:
The issue I'm running into is, I can't extend it with further timer advances like so:
I assumed this would pass due to the recursive nature of
getNextMatchFromLoop
, but it's not. Any ideas?In this particular case, I am mocking
const nextMatchResponse = await getNextMatch()
using msw so that it will never be truthy and always hit thesetTimeout
recursive call.Beta Was this translation helpful? Give feedback.
All reactions