Jest · Function
jest.fn
jest.fn() creates a mock function that records calls and results. You can give it custom behavior or fixed, asynchronous, or one-time return values.
Last updated
Syntax
jest.fn(implementation?)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
mockFn.mock.callsmockFn.mock.resultsmockFn.mock.instancesmockFn.mockClear()mockFn.mockReset()mockFn.mockRestore()mockFn.mockImplementation()mockFn.mockReturnValue()