jest mock functions
mockFn.mockClear()
Clears all information stored in the mockFn.mock.calls, mockFn.mock.instances, mockFn.mock.contexts and mockFn.mock.results arrays. Often this is useful when you want to clean up a mocks usage data between two assertions.
mockFn.mockReset()
Does everything that mockFn.mockClear() does, and also replaces the mock implementation with an empty function, returning undefined.
mockFn.mockImplementation(fn)
Accepts a function that should be used as the implementation of the mock.
mockFn.mockReturnValue(value)
Accepts a value that will be returned whenever the mock function is called.
Shorthand for: jest.fn().mockImplementation(() => value);
mockFn.mockResolvedValue(value)
Useful to mock async functions in async tests
Shorthand for: jest.fn().mockImplementation(() => Promise.resolve(value));
mockFn.mockRejectedValue(value)
Useful to create async mock functions that will always reject
Shorthand for: jest.fn().mockImplementation(() => Promise.reject(value));