apollo-feature-requests
apollo-feature-requests copied to clipboard
Consider replacing mock link with wildcard-mock-link
Apollo's mock link for react is okay for basic testing but needs a lot of improvements, particularly when it comes to dealing with subscriptions. It's also impossible to assert against requests that were made or write mocks that can match requests using arbitrary variables.
wildcard-mock-link is fully compatible but with the following features added:
- Match requests with arbitrary variables.
- Provide mocks that match more than one request.
- Mock subscriptions and send subscription responses after setting up the MockedProvider in a test via method calls.
- Grab the mutation/query/subscription requests for use in test assertions.
- Can optionally pass
actfunction to it in order to simplify writing tests. - Ability to wait for pending requests to be fulfilled, including recursively dependent requests.
It's also fully tested and documented.
https://github.com/apollographql/apollo-client/issues/9738