Skip to main content

interface Spy.Fn<F>

The spied function type containing extra information about the function calls.

Extends: FuncInterface<F>, Spy.FnMeta<F>

Type parameters

NameConstraintsDescription
FFuncthe spied function type

Properties

calls

Returns an array containing, for each received spy call, the given parameters.

Definition

get calls(): Parameters<F>[];

Overrides

FnMeta.calls

isCalled

Returns true if the spy function has received at least one call.

Definition

get isCalled(): boolean;

Overrides

FnMeta.isCalled

nrCalls

Returns the number of calls this spy function has received.

Definition

get nrCalls(): number;

Overrides

FnMeta.nrCalls

Methods

clearCalls

Clears the spy functions' calls and nrCalls history.

Definition

clearCalls(): void;

Overrides

FnMeta.clearCalls

resetStub

Resets the implementation used for the next spy function call to the original one used at construction time.

Definition

resetStub(): void;

Overrides

FnMeta.resetStub

setStub

Sets a stub implementation for this spy function, which will be used instead of the current function implementation upon the next received call.

Definition

setStub(stub: Spy.FnStub<F> | undefined): void;

Parameters

NameTypeDescription
stubSpy.FnStub<F> | undefinedthe stub implementation to use

Overrides

FnMeta.setStub