reproduce failure case in integration test #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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