You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing unit tests one need to mock any response that would otherwise come from the graphql server. Given that setting up the wrong expectation for the mocked payload can lead to writing tests against the wrong schema. A utility function that can be used to validate that a given object match a given query would be really useful to have.
Example payload used as a mock response:
{user: {id: 'some-id',name: 'Smith'}}
The corresponding query is:
gql`query { user(id: $userId) { id }}`
As you can see the mock response does not match the query and it would be nice to be able to assert on that.
I would be happy to submit a PR with this, but would like to know if there is a place I start looking and where is the right interface we might want to have for it.
The text was updated successfully, but these errors were encountered:
I like this idea, @ecstasy2. Right now there isn't something like this as we take it for granted (ie. there test cases covering) that the response of executing a query matches the query.
When writing unit tests one need to mock any response that would otherwise come from the graphql server. Given that setting up the wrong expectation for the mocked payload can lead to writing tests against the wrong schema. A utility function that can be used to validate that a given object match a given query would be really useful to have.
Example payload used as a mock response:
The corresponding query is:
As you can see the mock response does not match the query and it would be nice to be able to assert on that.
I would be happy to submit a PR with this, but would like to know if there is a place I start looking and where is the right interface we might want to have for it.
The text was updated successfully, but these errors were encountered: