1 |
|
2 | import { MatchersOrLiterals } from './Matchers';
|
3 | import { DeepPartial } from 'ts-essentials';
|
4 | type ProxiedProperty = string | number | symbol;
|
5 | export interface GlobalConfig {
|
6 | ignoreProps?: ProxiedProperty[];
|
7 | }
|
8 | export declare const JestMockExtended: {
|
9 | DEFAULT_CONFIG: GlobalConfig;
|
10 | configure: (config: GlobalConfig) => void;
|
11 | resetConfig: () => void;
|
12 | };
|
13 | export interface CalledWithMock<T, Y extends any[]> extends jest.Mock<T, Y> {
|
14 | calledWith: (...args: Y | MatchersOrLiterals<Y>) => jest.Mock<T, Y>;
|
15 | }
|
16 | export type _MockProxy<T> = {
|
17 | [K in keyof T]: T[K] extends (...args: infer A) => infer B ? T[K] & CalledWithMock<B, A> : T[K];
|
18 | };
|
19 | export type MockProxy<T> = _MockProxy<T> & T;
|
20 | export type _DeepMockProxy<T> = {
|
21 | [K in keyof T]: T[K] extends (...args: infer A) => infer B ? T[K] & CalledWithMock<B, A> : T[K] & _DeepMockProxy<T[K]>;
|
22 | };
|
23 | export type DeepMockProxy<T> = _DeepMockProxy<T> & T;
|
24 | export type _DeepMockProxyWithFuncPropSupport<T> = {
|
25 | [K in keyof T]: T[K] extends (...args: infer A) => infer B ? CalledWithMock<B, A> & DeepMockProxy<T[K]> : DeepMockProxy<T[K]>;
|
26 | };
|
27 | export type DeepMockProxyWithFuncPropSupport<T> = _DeepMockProxyWithFuncPropSupport<T> & T;
|
28 | export interface MockOpts {
|
29 | deep?: boolean;
|
30 | fallbackMockImplementation?: (...args: any[]) => any;
|
31 | }
|
32 | export declare const mockClear: (mock: MockProxy<any>) => any;
|
33 | export declare const mockReset: (mock: MockProxy<any>) => any;
|
34 | export declare function mockDeep<T>(opts: {
|
35 | funcPropSupport?: true;
|
36 | fallbackMockImplementation?: MockOpts['fallbackMockImplementation'];
|
37 | }, mockImplementation?: DeepPartial<T>): DeepMockProxyWithFuncPropSupport<T>;
|
38 | export declare function mockDeep<T>(mockImplementation?: DeepPartial<T>): DeepMockProxy<T>;
|
39 | declare const mock: <T, MockedReturn extends _MockProxy<T> & T = _MockProxy<T> & T>(mockImplementation?: DeepPartial<T>, opts?: MockOpts) => MockedReturn;
|
40 | export declare const mockFn: <T extends Function, A extends any[] = T extends (...args: infer AReal) => any ? AReal : any[], R = T extends (...args: any) => infer RReal ? RReal : any>() => CalledWithMock<R, A> & T;
|
41 | export declare const stub: <T extends object>() => T;
|
42 | export default mock;
|