-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add expected/received variables to 'No more mocked responses' error message #8340
Add expected/received variables to 'No more mocked responses' error message #8340
Conversation
@markneub: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
adf586c
to
95f68ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markneub Looks good to me, with some minor error message formatting tweaks. You're going to make a lot of developers a lot less confused when their mock variables don't match. Thanks!
Expected variables: {"username":"other_user","age":<undefined>} | ||
|
||
Failed to match 1 mock for this query, which had the following variables: | ||
{"username":"mock_username"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my changes, undefined values now print as <undefined>
rather than "undefined"
. This makes sense because these values are not actually strings, and while the <undefined>
syntax is not legal JSON, that's fine because these strings are just for display (not for JSON.parse
to consume later).
These changes should be available now in |
Updated version of abandoned PR #6963
Checklist:
Motivation
When testing a request using the MockedProvider, sometimes a mocked response is not found because the variables provided do not match the mock. It can be hard to tell what the differences are — this PR prints out the expected variables and the found variables, including variables that are set to
undefined
(fixes #6771).Sample Test Output
General use should error if the variables in the mock and component do not match
General use should error if the variables do not deep equal
General use should error if the query in the mock and component do not match