Skip to content
masterclass Buddy

Jest · Matcher

toHaveBeenCalledTimes

toHaveBeenCalledTimes(number) checks that a Jest mock function was called exactly the given number of times.

Last updated

Syntax

expect(mockFunction).toHaveBeenCalledTimes(number)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • expect(value)
  • toHaveBeenCalled()
  • toHaveBeenCalledWith(arg1, arg2, ...)
  • toHaveBeenLastCalledWith(arg1, arg2, ...)
  • jest.useFakeTimers()
  • jest.runAllTimers()
  • jest.runOnlyPendingTimers()
  • jest.advanceTimersByTime(msToRun)

Source: Expect · Jest. Checked 2026-11-03.