Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

MockedProvider #4018

Open
sgentile opened this issue Jun 10, 2020 · 1 comment
Open

MockedProvider #4018

sgentile opened this issue Jun 10, 2020 · 1 comment

Comments

@sgentile
Copy link

I've been writing tests and running into quite a bit of an issue with the "No more mocked responses for the query" error.

Reading this article https://medium.com/@emmanuellaaninye/errors-when-testing-apollo-graphql-in-react-no-more-mocked-responses-for-the-query-fe1b54756491 highlights all the issues around testing.

I'm not sure I quite get the design behind this MockedProvider. No where in the documentation does it cover how to use it. Actually based on documentation it would seem this is rather straightforward: (1) provide your mock input (2) provide your mock output. Done.

That said then, why are we needing to 'pass multiple identical' mocks in. Why are we needing to match a specific 'property order'. And why isn't the failed message writing out something like 'you passed 'xyz' we expected 'abc' ?

this is it right here:
https://www.apollographql.com/docs/react/api/react-testing/#mockedprovider

it says "doesn't send out network requests to your API, but rather allows you to specify the exact response payload for a given request". If that is the case, and based on that example, why would I ever get a "No more mocked responses for the query" error ? And why isn't that mentioned here ?

@MLKiiwy
Copy link

MLKiiwy commented Jun 16, 2020

Honestly the MockedProvider seems to not be properly documented.

  • You have to create mocks with the exact same order of properties as your query ... this part is already weird.

  • in lot of cases my queries are returning undefined values ... the mocked provider works (the no mocked response error is not throwing) => I try to find reproducible steps for this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants