Testing · Middle · Question 6 of 75

How do you use fake timers together with user-event v14?

vi.useFakeTimers();
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });

Explanation

Without it, user-event's delay waits on a setTimeout that never fires and the test times out.

Further reading

Problem with a question

Testing · Middle · question 6

Test yourself

Take the Testing · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz