Jest · Function
jest.mock
jest.fn() creates a mock function, also called a spy. It records how code calls the function and lets a test control its implementation or returned values.
Last updated
Syntax
jest.fn(implementation?)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
jest.spyOn()mockFn.mock.callsmockFn.mock.resultsmockFn.mock.instancesmockFn.mock.contextsmockFn.mockClear()mockFn.mockReset()mockFn.mockRestore()