Skip to main content

Function: verify()

verify<T>(method, customMessage?): MethodStubVerificator<T>

Defined in: ts-mockito.ts:100

Starts a verification of how many times (and in what order) a mocked method was called with the given arguments, or matchers in their place.

Type Parameters

T

T

Parameters

method

T

a call made on a mock, e.g. mockedFoo.getBar(3)

customMessage?

string

an optional message prepended to the failure output if the verification fails, e.g. for extra context (like jest-expect-message's custom messages)

Returns

MethodStubVerificator<T>

a MethodStubVerificator with .once(), .times(n), .calledBefore(), etc.

Example

verify(mockedFoo.getBar(3)).once();
verify(mockedFoo.getBar(anything())).called();
verify(mockedFoo.getBar(3), 'getBar should have been called with 3').once();