RunnerMock
interface in meocord/testing Since 4.2.0
interface RunnerMock {
(...args: any[]): any
}A mock function a test runner makes, as useMockFn takes it.
It is callable, records its calls in mock.calls, and has mockImplementation, mockClear and mockReset.
Vitest's vi.fn, jest's jest.fn and bun's mock make one.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] |
Returns
anyMembers
mock
mock: { calls: readonly unknown[][] }The calls the mock has recorded, each an array of its arguments.
mockImplementation
mockImplementation(fn: (...args: any[]) => any): unknownSets the implementation the mock runs.
Parameters
| Name | Type | Description |
|---|---|---|
fn | (...args: any[]) => any |
Returns
unknownmockClear
mockClear(): unknownForgets the calls the mock has recorded.
Returns
unknownmockReset
mockReset(): unknownForgets the calls and what the mock was told to do.
Returns
unknown