Vitest · Type Alias
MockInstance
Vitest MockInstance objects let tests inspect calls and control mock functions, spies, and mocked classes. Use vi.fn for a new mock and vi.spyOn for an existing object method.
Last updated
Syntax
vi.fn(implementation?)
vi.spyOn(object, method)
vi.mock(path, factory?)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
vi.fnvi.spyOnvi.mockvi.hoistedmock.callsmock.instancestoHaveBeenCalled