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
I'm trying to use mockServer as a mocking solution for my unit tests, storybook and integration tests.
Whenever a graphQL query is made when in a testing environment, it is hitting mockServer.query() correctly and responding with the default mocks I have set.
However of course when testing things with unit tests, you often want to override some results to test different scenarios. From reading the documentation I thought that was the whole point of the mockStore (to get, set and reset the store as needed for new mocks).
However after spending hours trying to use it. I cannot figure out any way to get this mockStore to actually return the values I set in mockServer???
and when I run a query (whether in my test or in my code)
constresult=awaitmockServer.query('query { user { rbac } }')expect(result).toEqual({test: true})
After setting the mockStore mock to be something specific, I am naturally expecting to get that response back? But everything I have tried so far has failed :(
The only way I have been able to get results from the store is by directly calling mockStore.get(xxx) which is not helpful when relying on mockServer with queries, and I can't find any explanation of how to actually use it in the docs aside from making custom resolvers which is not what I'm trying to do.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to use
mockServer
as a mocking solution for my unit tests, storybook and integration tests.Whenever a graphQL query is made when in a testing environment, it is hitting
mockServer.query()
correctly and responding with the default mocks I have set.However of course when testing things with unit tests, you often want to override some results to test different scenarios. From reading the documentation I thought that was the whole point of the mockStore (to get, set and reset the store as needed for new mocks).
However after spending hours trying to use it. I cannot figure out any way to get this mockStore to actually return the values I set in
mockServer
???E.g. if I do:
and when I run a query (whether in my test or in my code)
After setting the mockStore mock to be something specific, I am naturally expecting to get that response back? But everything I have tried so far has failed :(
The only way I have been able to get results from the store is by directly calling
mockStore.get(xxx)
which is not helpful when relying on mockServer with queries, and I can't find any explanation of how to actually use it in the docs aside from making custom resolvers which is not what I'm trying to do.Beta Was this translation helpful? Give feedback.
All reactions