Unable to retrieve application context. Did you forget to wrap your App inside `withTRPC` HoC?

Hey, noob question but am not sure how to deal with it. I recently added tRPC to my existing project, everything except my jest tests is working fine. When I try to render a component that's calling tRPC api.example.hello.useQuery({ text: 'from tRPC' }); it breaks my tests. Not really sure how to wrap my render function withTRPC. I literally just have the tRPC setup and then a render(<Component />)
3 Replies
cje
cje14mo ago
trpc needs some providers to work, so when you just render a component to a fake DOM it doesn't work
cje
cje14mo ago
heres a full testing setup, repo is a few months old but should still work https://github.com/c-ehrlich/msw-trpc-example
GitHub
GitHub - c-ehrlich/msw-trpc-example
Contribute to c-ehrlich/msw-trpc-example development by creating an account on GitHub.
gilhrpenner
gilhrpenner14mo ago
Thank you! That was super helpful!
Want results from more Discord servers?
Add your server