- Notifications
You must be signed in to change notification settings - Fork833
reproduce failure case in integration test#153
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
reproduce failure case in integration test#153
Uh oh!
There was an error while loading.Please reload this page.
Conversation
apollo-cla commentedJul 8, 2020
@kamleshchandnani: 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/ |
@stemmlerjs@JakeDawkins@hwillson If you can provide some inputs on this? |
So it looks like the reason the errorFromResponse function isn't being called is because you're overwriting the |
I don't think this is a bug, but rather just a difficult thing to mock. I'd have to do a little more investigation to figure out a clear story for mocking this, but I don't think I have time anytime soon to dig into that |
kamleshchandnani commentedJul 9, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@JakeDawkins Ah okay. I tried to mock the underlying fetch but seems like it's not trivial and I didn't had any luck to make it work 😓 The problem is I can't really mock the underlying fetch because it's jut not the fetch there's more stuff going in there inside the |
@stemmlerjs@JakeDawkins@hwillson can anyone of you help with any other alternative way of achieving this? |
Uh oh!
There was an error while loading.Please reload this page.
Basically the problem is that when one of our datasource methods triggers an error then the
errorFromResponse
method is called and then the error is returned and we see that error in our playground but when you try to test it and mock the error in your test the error you get from query/mutation method fromapollo-server-testing
are both different.In this PR to reproduce this issue what I've done is I changed the endpoint of spaceX and made it point to
launch
instead oflaunches
which doesn't exist so the datasource method will get triggered and then I've overwrittenerrorFromResponse
to handle the errors and what I'm doing there is I'm sending aApolloError
with custom message.Now when you open it in playground and run the query
getLaunchById
it'll throw the error and the error object looks something like thisNow I want to test this and assert that my error object is same as one returned when I actually run this query. So what I did was in my test I just mock the datasource
get
method and reject it's value withNot Found
here at this line but now when I execute my query inside the test the response object returned(which is error object) inside my test is thisand when I do
expect(res).toEqual(errorFromPlayground);
it fails because obviously the two objects are different. Now the question is why are these objects different and how do I make this assertion pass?Reproduces#154