Testing · Junior · Question 38 of 78

What does mockClear() (or vi.clearAllMocks()) do?

Explanation

Without clearing, calls from the previous test leak into the next one and toHaveBeenCalledTimes gives wrong numbers.

Further reading

Problem with a question

Testing · Junior · question 38

Test yourself

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

Take this quiz