apollo-feature-requests icon indicating copy to clipboard operation
apollo-feature-requests copied to clipboard

Consider replacing mock link with wildcard-mock-link

Open insidewhy opened this issue 4 years ago โ€ข 1 comments

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 act function 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.

insidewhy avatar Jun 11 '21 16:06 insidewhy

https://github.com/apollographql/apollo-client/issues/9738

jpvajda avatar May 25 '22 17:05 jpvajda