Vitest · Matcher
toHaveBeenCalled
expect(spy).toHaveBeenCalled() checks that a mock or spy function ran at least once. Add .not to assert that it was not called.
Last updated
Syntax
expect(actual).toHaveBeenCalled()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
toHaveBeenCalledTimestoHaveBeenCalledWithtoHaveBeenCalledExactlyOnceWithtoHaveBeenLastCalledWithtoHaveBeenNthCalledWithvi.fnvi.spyOn