Vitest · Method
vi.getMockName
Vitest provides vi.fn and vi.spyOn for creating and observing mock functions. They record calls and let you replace function behavior for tests.
Last updated
Syntax
vi.fn(implementation?)
vi.spyOn(object, method)
mockImplementation(fn)
mockImplementationOnce(fn)
mockClear()
getMockImplementation()
getMockName()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
vi.fnvi.spyOnmockClearmockImplementationmockImplementationOncemockNamegetMockImplementationgetMockName