UNPKG

strong-mock

Version:

Type safe mocking library for TypeScript

22 lines (21 loc) 660 B
import type { TypeMatcher } from './matcher'; /** * Matches anything and stores the received value. * * This should not be needed for most cases, but can be useful if you need * access to a complex argument outside the expectation e.g. to test a * callback. * * @param name If given, this name will be printed in error messages. * * @example * const fn = mock<(cb: (value: number) => number) => void>(); * const matcher = It.willCapture(); * when(() => fn(matcher)).thenReturn(); * * fn(x => x + 1); * matcher.value?.(3) === 4 */ export declare const willCapture: <T = unknown>(name?: string) => TypeMatcher<T> & { value: T | undefined; };