Testing · Middle · Question 16 of 75

Why does vi.spyOn(module, "fn") often fail to affect calls inside the same ES module?

Explanation

Mock the module with vi.mock or move the dependency to another module / inject it.

Further reading

Problem with a question

Testing · Middle · question 16

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