rest-vir - v2.2.0
    Preparing search index...

    Function createMockFetch

    • Creates a mock fetch function that always returns a mock Response object based on the given response parameters. For more control over a mocked fetch, use createMockResponse directly. See createMockEndpointFetch for a more type safe version, specific to individual endpoints.

      Parameters

      Returns {
          (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
          (input: string | URL | Request, init?: RequestInit): Promise<Response>;
      }

        • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
        • Parameters

          • input: URL | RequestInfo
          • Optionalinit: RequestInit

          Returns Promise<Response>

        • (input: string | URL | Request, init?: RequestInit): Promise<Response>
        • Parameters

          • input: string | URL | Request
          • Optionalinit: RequestInit

          Returns Promise<Response>

      import {createMockFetch, fetchEndpoint} from '@rest-vir/api';

      fetchEndpoint(myService.endpoints['/my-path'], {
      fetch: createMockFetch({
      body: 'some body',
      // there are other properties that can be mocked as well, see the types for more details
      }),
      });