Testing · Middle · Question 14 of 75
What does mockImplementationOnce allow?
fetchUser
.mockRejectedValueOnce(new Error("timeout"))
.mockResolvedValueOnce({ name: "Ann" });- ✓Correct answer: Different results for consecutive calls - e.g. fail first, then succeed to test a retry
- 2Running the mock only in the first test
- 3Calling the real implementation once
Explanation
After the “once” values run out, the default implementation (if any) is used.