Skip to main content

SettledTrackingMiddleware

Callable


  • The primary goal of this middleware is to expose a mechanism for consumers to know when all requests are completed. This is very useful for testing purposes where you may want to author tests in a higher level way (e.g. “click this button and confirm some content is updated”).

    Note: This middleware is intended to be used in non-production contexts (e.g. when debugging or running tests).

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

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

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

    await requestsCompleted(fetch);

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

    Parameters

    Returns Promise<Response>