Skip to content
GitHub

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

NameTypeDescription
...argsany[]

Returns

any

Members

mock

mock: { calls: readonly unknown[][] }

The calls the mock has recorded, each an array of its arguments.

mockImplementation

mockImplementation(fn: (...args: any[]) => any): unknown

Sets the implementation the mock runs.

Parameters

NameTypeDescription
fn(...args: any[]) => any

Returns

unknown

mockClear

mockClear(): unknown

Forgets the calls the mock has recorded.

Returns

unknown

mockReset

mockReset(): unknown

Forgets the calls and what the mock was told to do.

Returns

unknown

See also