strong-mock
Version:
Type safe mocking library for TypeScript
25 lines (24 loc) • 857 B
TypeScript
import type { MockOptions } from './options';
export type Mock<T> = T;
/**
* Create a type safe mock.
*
* @see {@link when} Set expectations on the mock using `when`.
*
* @param options Configure the options for this specific mock, overriding any
* defaults that were set with {@link setDefaults}.
* @param options.unexpectedProperty Controls what happens when an unexpected
* property is accessed.
* @param options.concreteMatcher The matcher that will be used when one isn't
* specified explicitly.
* @param options.exactParams Controls whether the number of received arguments
* has to match the expectation.
*
* @example
* const fn = mock<() => number>();
*
* when(() => fn()).thenReturn(23);
*
* fn() === 23;
*/
export declare const mock: <T>({ unexpectedProperty, concreteMatcher, exactParams, }?: MockOptions) => Mock<T>;