• Version 1.22.0
  • Published
  • 68.1 kB
  • 2 dependencies
  • MIT license


npm i axios-mock-adapter
yarn add axios-mock-adapter
pnpm add axios-mock-adapter


Axios adapter that allows to easily mock requests



class MockAdapter

class MockAdapter {}


    constructor(axiosInstance: AxiosInstance, options?: MockAdapterOptions);

      property default

      static default: typeof MockAdapter;

        property history

        history: { [method: string]: AxiosRequestConfig[] };

          property onAny

          onAny: RequestMatcherFunc;

            property onDelete

            onDelete: RequestMatcherFunc;

              property onGet

              onGet: RequestMatcherFunc;

                property onHead

                onHead: RequestMatcherFunc;
                  onLink: RequestMatcherFunc;

                    property onList

                    onList: RequestMatcherFunc;

                      property onOptions

                      onOptions: RequestMatcherFunc;

                        property onPatch

                        onPatch: RequestMatcherFunc;

                          property onPost

                          onPost: RequestMatcherFunc;

                            property onPut

                            onPut: RequestMatcherFunc;
                              onUnlink: RequestMatcherFunc;

                                method adapter

                                adapter: () => AxiosAdapter;

                                  method reset

                                  reset: () => void;

                                    method resetHandlers

                                    resetHandlers: () => void;

                                      method resetHistory

                                      resetHistory: () => void;

                                        method restore

                                        restore: () => void;


                                          interface RequestHandler

                                          interface RequestHandler {}

                                            property reply

                                            reply: ResponseSpecFunc;

                                              property replyOnce

                                              replyOnce: ResponseSpecFunc;

                                                method abortRequest

                                                abortRequest: () => MockAdapter;

                                                  method abortRequestOnce

                                                  abortRequestOnce: () => MockAdapter;

                                                    method networkError

                                                    networkError: () => MockAdapter;

                                                      method networkErrorOnce

                                                      networkErrorOnce: () => MockAdapter;

                                                        method passThrough

                                                        passThrough: () => MockAdapter;

                                                          method timeout

                                                          timeout: () => MockAdapter;

                                                            method timeoutOnce

                                                            timeoutOnce: () => MockAdapter;

                                                              Package Files (1)

                                                              Dependencies (2)

                                                              Dev Dependencies (11)

                                                              Peer Dependencies (1)


                                                              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>