• Version 3.0.7
  • Published
  • 73 kB
  • 1 dependency
  • MIT license


npm i jest-mock-extended
yarn add jest-mock-extended
pnpm add jest-mock-extended


Type safe mocking extensions for jest



variable any

const any: MatcherCreator<any, any>;

    variable anyArray

    const anyArray: MatcherCreator<any[], any[]>;

      variable anyBoolean

      const anyBoolean: MatcherCreator<boolean, boolean>;

        variable anyFunction

        const anyFunction: MatcherCreator<Function, Function>;

          variable anyMap

          const anyMap: MatcherCreator<Map<any, any>, Map<any, any>>;

            variable anyNumber

            const anyNumber: MatcherCreator<number, number>;

              variable anyObject

              const anyObject: MatcherCreator<any, any>;

                variable anySet

                const anySet: MatcherCreator<Set<any>, Set<any>>;

                  variable anyString

                  const anyString: MatcherCreator<string, string>;

                    variable anySymbol

                    const anySymbol: MatcherCreator<Symbol, Symbol>;

                      variable arrayIncludes

                      const arrayIncludes: MatcherCreator<any[], any>;

                        variable isA

                        const isA: MatcherCreator<any, any>;

                          variable JestMockExtended

                          const JestMockExtended: {
                          DEFAULT_CONFIG: GlobalConfig;
                          configure: (config: GlobalConfig) => void;
                          resetConfig: () => void;

                            variable mapHas

                            const mapHas: MatcherCreator<Map<any, any>, any>;

                              variable notEmpty

                              const notEmpty: MatcherCreator<any, any>;

                                variable notNull

                                const notNull: MatcherCreator<any, any>;

                                  variable notUndefined

                                  const notUndefined: MatcherCreator<any, any>;

                                    variable objectContainsKey

                                    const objectContainsKey: MatcherCreator<any, string>;

                                      variable objectContainsValue

                                      const objectContainsValue: MatcherCreator<any, any>;

                                        variable setHas

                                        const setHas: MatcherCreator<Set<any>, any>;


                                          function calledWithFn

                                          calledWithFn: <T, Y extends any[]>({
                                          }?: {
                                          fallbackMockImplementation?: (...args: Y) => T;
                                          }) => CalledWithMock<T, Y>;

                                            function captor

                                            captor: <T extends unknown = any>() => CaptorMatcher<T>;

                                              function matches

                                              matches: <T extends unknown = any>(matcher: MatcherFn<T>) => Matcher<T>;

                                                function mock

                                                mock: <T, MockedReturn extends _MockProxy<T> & T = _MockProxy<T> & T>(
                                                mockImplementation?: any,
                                                opts?: import('./Mock').MockOpts | undefined
                                                ) => MockedReturn;

                                                  function mockClear

                                                  mockClear: (mock: MockProxy<any>) => any;

                                                    function mockDeep

                                                    mockDeep: {
                                                    opts: {
                                                    funcPropSupport?: true;
                                                    fallbackMockImplementation?: MockOpts['fallbackMockImplementation'];
                                                    mockImplementation?: DeepPartial<T>
                                                    ): DeepMockProxyWithFuncPropSupport<T>;
                                                    <T>(mockImplementation?: DeepPartial<T>): DeepMockProxy<T>;

                                                      function mockFn

                                                      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;

                                                        function mockReset

                                                        mockReset: (mock: MockProxy<any>) => any;

                                                          function stub

                                                          stub: <T extends object>() => T;


                                                            class CaptorMatcher

                                                            class CaptorMatcher<T> {}



                                                                property $$typeof

                                                                $$typeof: Symbol;

                                                                  property asymmetricMatch

                                                                  readonly asymmetricMatch: MatcherFn<T>;

                                                                    property value

                                                                    readonly value: {};

                                                                      property values

                                                                      readonly values: T[];

                                                                        method getExpectedType

                                                                        getExpectedType: () => string;

                                                                          method toAsymmetricMatcher

                                                                          toAsymmetricMatcher: () => string;

                                                                            method toString

                                                                            toString: () => string;

                                                                              class Matcher

                                                                              class Matcher<T> {}


                                                                                constructor(asymmetricMatch: MatcherFn<T>, description: string);

                                                                                  property $$typeof

                                                                                  $$typeof: Symbol;

                                                                                    property asymmetricMatch

                                                                                    readonly asymmetricMatch: MatcherFn<T>;

                                                                                      property inverse

                                                                                      inverse?: boolean;

                                                                                        method getExpectedType

                                                                                        getExpectedType: () => string;

                                                                                          method toAsymmetricMatcher

                                                                                          toAsymmetricMatcher: () => string;

                                                                                            method toString

                                                                                            toString: () => string;


                                                                                              interface CalledWithMock

                                                                                              interface CalledWithMock<T, Y extends any[]> extends jest.Mock<T, Y> {}

                                                                                                property calledWith

                                                                                                calledWith: (...args: Y | MatchersOrLiterals<Y>) => jest.Mock<T, Y>;

                                                                                                  interface GlobalConfig

                                                                                                  interface GlobalConfig {}

                                                                                                    property ignoreProps

                                                                                                    ignoreProps?: ProxiedProperty[];

                                                                                                      interface MatcherCreator

                                                                                                      interface MatcherCreator<T, E = T> {}

                                                                                                        call signature

                                                                                                        (expectedValue?: E): Matcher<T>;

                                                                                                          Type Aliases

                                                                                                          type DeepMockProxy

                                                                                                          type DeepMockProxy<T> = _DeepMockProxy<T> & T;

                                                                                                            type MatcherFn

                                                                                                            type MatcherFn<T> = (actualValue: T) => boolean;

                                                                                                              type MatchersOrLiterals

                                                                                                              type MatchersOrLiterals<Y extends any[]> = {
                                                                                                              [K in keyof Y]: Matcher<Y[K]> | Y[K];

                                                                                                                type MockProxy

                                                                                                                type MockProxy<T> = _MockProxy<T> & T;

                                                                                                                  Package Files (3)

                                                                                                                  Dependencies (1)

                                                                                                                  Dev Dependencies (7)

                                                                                                                  Peer Dependencies (2)


                                                                                                                  To add a badge like this badgeto your package's README, use the codes available below.

                                                                                                                  You may also use to create a custom badge linking to

                                                                                                                  • Markdown
                                                                                                                  • HTML
                                                                                                                    <a href=""><img src="" alt=""></a>