core3-utils

@wixc3/testing on Github

Home > @wixc3/testing > waitForSpyCall

waitForSpyCall() function

Spies on an object method, waiting until it’s called. The spy is removed once called

Signature:

export declare function waitForSpyCall<S extends object>(scope: S, method: keyof S | S[keyof S]): PromiseWithTimeout<any[]>;

Parameters

Parameter Type Description
scope S
method keyof S \| S\[keyof S\]

Returns:

PromiseWithTimeout<any[]>

Example

const call = waitForSpyCall(target, 'method');
target.method(1, 'success');
expect(await call).to.eql([1, 'success']);