rest-vir - v1.0.0
    Preparing search index...

    Function createMockEndpointFetch

    • Creates a mock fetch function that returns a mock Response object that matches the expectations of the given endpoint. For more generic fetch mocking, see createMockFetch.

      Type Parameters

      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 {createMockEndpointFetch, fetchEndpoint} from '@rest-vir/define-service';

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