Skip to content
masterclass Buddy

Vitest · Matcher

toHaveBeenCalledWith

Checks whether a spy or mock was called at least once with specific arguments. Pass the expected arguments to toHaveBeenCalledWith.

Last updated

Syntax

expect(spy).toHaveBeenCalledWith(...args)

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

Subscribe
  • toHaveBeenCalledTimes
  • toHaveBeenCalledExactlyOnceWith
  • toHaveBeenLastCalledWith
  • toHaveBeenCalledBefore
  • toHaveBeenCalledAfter

Source: expect | Vitest. Checked 2026-11-03.