Testing · Junior · Question 34 of 78

What does jest.spyOn(obj, "method") / vi.spyOn do?

Explanation

Add .mockImplementation(...) to replace the behaviour, and restore the original with mockRestore() after the test.

Further reading

Problem with a question

Testing · Junior · question 34

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