xhr-mock

  • Version 2.5.1
  • Published
  • 179 kB
  • 2 dependencies
  • MIT license

Install

npm i xhr-mock
yarn add xhr-mock
pnpm add xhr-mock

Overview

Utility for mocking XMLHttpRequest.

Index

Variables

variable _default

const _default: XHRMock;

    Functions

    function delay

    delay: (mock: MockFunction | MockObject, ms?: number) => MockFunction;

      function once

      once: (mock: MockFunction | MockObject) => MockFunction;

        function proxy

        proxy: (req: MockRequest, res: MockResponse) => Promise<MockResponse>;

          function sequence

          sequence: (mocks: (MockFunction | MockObject)[]) => MockFunction;

            Classes

            class MockRequest

            class MockRequest {}

              method body

              body: { (): any; (body: any): MockRequest };

                method header

                header: {
                (name: string): null | string;
                (name: string, value: string): MockRequest;
                };

                  method headers

                  headers: { (): MockHeaders; (headers: MockHeaders): MockRequest };

                    method method

                    method: { (): string; (method: string): MockRequest };

                      method url

                      url: { (): MockURL; (url: string): MockRequest };

                        class MockResponse

                        class MockResponse {}

                          method body

                          body: { (): any; (body: any): MockResponse };

                            method header

                            header: {
                            (name: string): null | string;
                            (name: string, value: string): MockResponse;
                            };

                              method headers

                              headers: { (): MockHeaders; (headers: MockHeaders): MockResponse };

                                method reason

                                reason: { (): string; (reason: string): MockResponse };

                                  method status

                                  status: { (): number; (status: number): MockResponse };

                                    method statusText

                                    statusText: { (): null | string; (reason: string): MockResponse };

                                      Package Files (8)

                                      Dependencies (2)

                                      Dev Dependencies (11)

                                      Peer Dependencies (0)

                                      No peer dependencies.

                                      Badge

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

                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/xhr-mock.

                                      • Markdown
                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/xhr-mock)
                                      • HTML
                                        <a href="https://www.jsdocs.io/package/xhr-mock"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>