I'm trying to test a component that uses graphql, but when using Apollo's MockProvider I never get the data, it just says loading = true every time.
A complete, minimalist example is here
Things I've tried:
- Looking online (found this similar question, but since it had no answer I thought I'd make a new one with more information)
- Tried exporting components without the graphql when testing (
export function Component
), but that doesn't work when testing nested components - Tried simplifying as much as possible (the results of which is in the example)
Yup I ran into this issue as well. The funny thing was that if I add console logs to the component itself, I could see that the data ended up getting there just fine. But for some reason the
wrapper
would still only contain our "Loading ..." UI.Turns out you need to call
wrapper.update()
to get the wrapper to rerender it's contents.This is what worked for me, but it seems less than ideal, so if anyone else has a workaround let me know! Right now our tests look something like: