-
Notifications
You must be signed in to change notification settings - Fork 787
feat req: Improve "No more mocked responses for the query" message #3013
Comments
@FernandoBasso I'm staring at one of these right now. You mention adding something in particular for the It's most frustrating to me that when the |
So, my rationale is that we have a normal query and mutation, and we can mock them. But then, we can also have Another situation is when our mocked query is different (params, fields, etc) from the original query, and again, the same "no more mocked responses for the query" message is displayed. But in such cases we have no way to know where in the code our mocked response differs from the original one. It would be very helpful if the message were more specific, saying that our mocked response differs (and where) instead of just saying there are no more mocked responses. So, @KosnIre, I don't mean only for As a side note, I have invested lots of time trying to mock very large responses. I guess such improvement would help immensely in such cases as well. |
Ok thanks @FernandoBasso. I guess my wording was poor, but you have helped fix my issue (at least this one-- I would love to see some more specific errors like you suggest here).
I'm still new to using Apollo, so I did not even realize that I had to add more mocked responses for each request the test-case makes! I don't think the documentation does a very good job of explaining this. I was able to find where the code removes mocked responses as it uses them. That behavior seems strange to me, but I guess that is off-topic. Better error messages would have helped me figure that out sooner. I guess the hard part about showing the differences is that the MockLink doesn't explicitly know which one is supposed to match. So you would have to make a guess, maybe based on the query name. |
I just ran across a really bad version of this, that having better logs or reasoning would have helped a lot. Basically my operation's variables was this object:
But my mock variables was this object:
The best part is that if you Having something that says something like:
Would be SO HELPFUL! |
Looks like this is the line you're looking for. Gonna try to draw up a PR for it in a few days: react-apollo/src/test-links.ts Line 77 in 3381ade
|
To help provide a more clear separation between feature requests and bugs, and to help clean up the feature request backlog, React Apollo feature requests are now being managed under the https://github.com/apollographql/apollo-feature-requests repository. Migrated to apollographql/apollo-feature-requests#115. |
It would be very nice and useful if instead of a simply returning "No more mocked responses for the query", the message would also point out where (or how) the mocked response differ from what is expected.
In my (so far) brief experience with
MockedProvider
, that message generally arises from different mocked responses, different variables, and things like those. Also, when yourefetch
orfetchMore
, and you don't provide the "extra" mocked responses.I have seen lots of issues and questions about this message, and I believe a more specific message would be of great help.
The text was updated successfully, but these errors were encountered: