Is there a way to mock a request without worrying about response? #2173
Unanswered
keerthana-tw
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi, @keerthana-tw. I'm not entirely sure what you are trying to do but I will presume you want to:
If I get that right, you can achieve that with the following request handler: // Intercept a GraphQL query called "getCart".
graphql.query('getCart', () => {
// Respond with an empty successful GraphQL response.
return Response.json({ data: {} })
}) I still recommend setting |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a VueJS frontend which uses vue apollo composables and uses msw to unit test the components. There are many places where I have provided refetchQueries as array of query names. i.e
Now, the getCart query might have been triggered in some parent component and in actual application it works well. When it comes to unit testing the modal that uses this mutation, I am getting console errors saying
Unknown query named "getCart" requested in refetchQueries options.include array
.I do not want to silence these error logs at global level as it might lead to case where I actually misspelled the query and it goes unnoticed. Is there a way I can configure in one test like if a call to this query is found, ignore it?
Beta Was this translation helpful? Give feedback.
All reactions