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