rest-vir - v1.0.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: RequestInfo | URL, init?: RequestInit): Promise<Response>;
          (input: string | Request | URL, init?: RequestInit): Promise<Response>;
      }

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

          • input: RequestInfo | URL
          • Optionalinit: RequestInit

          Returns Promise<Response>

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

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

          Returns Promise<Response>

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

      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
      }),
      });