MockProvider returns undefined in the render for the mockdata passed #11326
Labels
🏓 awaiting-contributor-response
requires input from a contributor
ℹ needs-more-info
Needs more information to determine root cause
⁉️ question
🔬 testing-utilities
🥀 needs-reproduction
Hi,
Thanks for the huge community support.
We're facing an issue similar to others using MockProvider which returns undefined when the mock data is passed. I saw few of the issues raised in this forum. I've tried those. But didn't work.
Here is our env details
I thought of trying your sample tests as mentioned down below which is taken from github.com/apollographql/apollo-client/blob/main/src/testing/react/tests/MockedProvider.test.tsx with a little tweak of not passing the variables.
Even then it didn't work. What works is if we mock the useQuery inside the tests something like this.
(useQuery as jest.Mock).mockReturnValue({
loading: false,
error: undefined,
data: { user : { id : 1}}
})
Please advise how to fix this with MockProvider or something that i'm missing or should we need to follow the recommendations from your RFC: Revisiting Apollo Client's testing approach
The text was updated successfully, but these errors were encountered: