-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat req: Improve "No more mocked responses for the query" message #115
Comments
👋 I just spent an hour trying to figure out why my query and variables weren't matching and it turned out that the date strings i was passing to the query didn't match the Date objects getting passed into the actual It was frustratingly hard to debug because the error says:
and my mock looked identical :
a diff or a message about the types not matching would have been so helpful 😢 |
Would also be important to show how many mocked responses did match. In some cases there might fire more than one request and you have a mock only for the first one. With current error message it's not clear wether it matched any or some. |
Take a look in react-apollo/test-link.js inside your node_modules folder. Find the request method (Looks something like: I've spent hours trying to work out why I am getting missed when trying to mock requests as well. I hope this way helps you. EDIT: I am using react-apollo 2.5.3. I think this would be @apollo/react-testing in version 3 and beyond. EDIT 2: From looking around the code some more, those variables that are being generated by the unit under test are logged as part of the error but this was not obvious to me from the log. I have also noticed that the log sometimes doesn't show in the terminal for an unknown reason. The code is using the isEqual method from lodash to compare the variables in the mock to the variables in the request. I feel this might be a little too strict when the end user (i.e. us devs) is just trying to create a mock to force their test into a particular state. Maybe that's just me though. |
i am in the same situation atm, i am 100% sure my query, my variables and the amount of calls match, yet i get this error. this situation is UNDEBUGGABLE and wastes insane amounts of time trying things until by pure luck things start to work. |
MEGAFACEPALM. PLEASE, PLEASE add an extra error when no mocks are given at all:
|
Spent a few hours on this due to capitalization of a string, would love to see this implemented! |
I think the phrase itself is misleading: I'm pretty sure that I have no mock responses set up with my MockProvider yet I get: The phrasing should maybe be something like: "There is a mismatch between incoming requests and expected mock responses:" You have mock responses set up: [{query: blah, mockResponse: blah }]
And requests: [{query: blah, mockResponse: blah }, {query: blah, mockResponse: blah },]
diff:
actual:
+ {
query:
{
},
mockResponse: {
} }
expected:
|
Migrated from: apollographql/react-apollo#3013
The text was updated successfully, but these errors were encountered: