Skip to content
masterclass Buddy

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.

Subscribe
  • mockFn.mock.calls
  • mockFn.mock.results
  • mockFn.mock.instances
  • mockFn.mockClear()
  • mockFn.mockReset()
  • mockFn.mockRestore()
  • mockFn.mockImplementation()
  • mockFn.mockReturnValue()

Source: Mock Functions · Jest. Checked 2026-11-03.