Question · NestJS course · Module 7: Testing
Difference between Mock and Spy
What is the difference between jest.fn() and jest.spyOn()?
Answer options
- There is no difference
- fn() creates a new function, spyOn() monitors an existing method
- fn() is synchronous, spyOn() is asynchronous
- fn() is for classes, spyOn() is for functions
You can check the correct answer by solving this task in the CodeWorlds game.