-
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
Issue 5917 mocked provider onerror #10416
Issue 5917 mocked provider onerror #10416
Conversation
@yuhaoju: 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/ |
🦋 Changeset detectedLatest commit: 31fd91e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ju/apollo-client into issue-5917-mocked-provider-onerror
Hey @yuhaoju! Appreciate the contribution! I'm a bit concerned around this particular solution to the linked issue, particularly because it puts to onus on determining when there might be an issue back on the developer writing the test. This feels a little bit like we are asking the developer to pass this function so that you might "hope" to catch something. 95% of the time, that is just going to be added noise in your test with no benefit. Instead, I think it would make sense to log a warning to the console so that its seen in the test itself. This seems to match the ask from issue:
I also think this statement nails it:
Not matching a mock is a user-error mistake, and we should do our best to let you know something is misconfigured. The console warning would really help in that case. Would you instead be willing to pivot and display a console warning instead? I'd love for you to get contribution credit if you're still interested in contributing a solution. If not, no worries! We can close this PR and implement it ourselves. Let me know what you think! |
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.
(my previous comment has my feedback. Forgot to submit this as a formal review 😬 )
Hey @yuhaoju! Just wanted to give a gentle nudge and see if you'd be interested in moving this forward. No problem if not. Thanks! |
@jerelmiller Sorry for the late reply. I think in my case I do want to format the error message, like using jest-diff to compare and display mocked request params. There are some complex requests, and sometimes it's hard to find the difference from strings. But I also agree that it can be extra noise for the rest of scenarios, I guess displaying a warning message should be a better idea. So please feel free to close this PR and open another one. Thanks for your reply, I'd like to contribute if there is chance in the future. |
@yuhaoju totally understand your thinking here, I'm just not sure its the direction we want to move for the library itself. If you'd still like that ability, you might consider copying over the Thanks for the reply though and the contribution! |
Which problem does this PR solve?
MockedProvider doesn't log error when mock is missing, and provides no way to inspect the queries being made during a test. Issue: #5917
Main changes
onError()
prop toMockedProvider
onError()
fromMockedProvider
toMockLink
through param.MockLink
, check if custom error handler is defined and if it should run it.Checklist:
I will add unit tests if these changes look good.