Skip to content

mockHttpClientRequestOnce โ€‹

Only the next httpClient.request is mocked; the stub is not tied to a specific URL โ€” the first matching call wins. If many endpoints share one client, prefer the mockEndpointRequest* helpers for clearer scoping.

Restore the spy in afterEach when you are finished.

Example โ€” only the next request:

ts
mockHttpClientRequestOnce(httpClient, { success: { id: 1 } });
// this call is mocked:
await httpClient.request({ path: '/x', method: 'GET', format: 'json' });
// following calls use the real client again

Released under the MIT License.