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.
settledResults Since 4.2.1
readonly settledResults: MockSettledResult<Awaited<CallResult<T>>>[]Each call's outcome once it has settled, in order.
invocationCallOrder Since 4.2.1
readonly invocationCallOrder: number[]When each call came, as a number that grows across meocord's own mocks.
contexts Since 4.2.1
readonly contexts: unknown[]The this each call had, in order.