Skip to content
masterclass Buddy

Jest · Matcher

toHaveBeenCalledWith

Checks that a Jest mock function was called with a specified list of arguments. It uses toEqual-style comparison for those arguments.

Last updated

Syntax

expect(mock).toHaveBeenCalledWith(arg1, arg2, ...)

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

Subscribe
  • expect
  • toEqual
  • toHaveBeenLastCalledWith
  • toHaveBeenNthCalledWith
  • expect.any
  • expect.objectContaining
  • expect.arrayContaining

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