Skip to content
GitHub

MockState

interface in meocord/testing Since 4.0.0

interface MockState<T extends (...args: any[]) => any = (...args: any[]) => any>

What a mock function has recorded: each call's arguments, outcome and this, in order.

Read it as fn.mock. Jest's and Vitest's toHaveBeenCalledWith and the rest read it too.

Members

calls

readonly calls: CallArgs<T>[]

Arguments from each call, in order.

results

readonly results: MockResult<CallResult<T>>[]

Return / throw result from each call, in order.

instances

readonly instances: any[]

The this value recorded for each call.

lastCall

readonly lastCall?: CallArgs<T>

Arguments from the most recent call, or undefined if never called.

See also