Question 5 of 10Pro Only
How do you use mock functions with Jest? Explain jest.fn and jest.mock with examples.
Sample answer preview
Mocking is an essential technique for isolating the code you are testing from its dependencies. Jest provides powerful tools for creating mock functions and modules. jest.fn creates a mock function.
jest.fnjest.mockjest.spyOnmockReturnValuemockResolvedValuetoHaveBeenCalled