Skip to main content

requestsCompleted

Callable

  • requestsCompleted(originatingFetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>, _options?: RequestsCompletedOptions): Promise<unknown>

  • Exposes a mechanism to wait for all currently pending requests to be completed. This is useful in some testing contexts. For example, to know when any fetch related async is completed so that you can run various assertions on the results.

    @example
    import { requestsCompleted } from '@data-eden/network';
    import { fetch } from './my-app-buildFetch';

    test('updates data when submitted', async function() {
    await render(...);

    await click('[some-button]');

    await requestsCompleted(fetch);

    expect(document.querySelector('.some-content').textContent).toMatchSnapshot();
    });

    Parameters

    • originatingFetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
    • _options: RequestsCompletedOptions = {}

    Returns Promise<unknown>