Has anyone had any success unit testing components which use tRPC apis?
I'm having a difficult time wrapping my head around testing react components that use trpc apis.
Any success? Can you please share examples, posts, or repo links.
I'm not talking testing tRPC procedures but unit testing components that use tRPC apis like this - api.upload_image.useMutation().
So far, I've got this - https://github.com/trpc/trpc/discussions/4899
But the problem I'm facing with this setup is that, while running tests, when I console log tRPC instance -
Thank you.
Any success? Can you please share examples, posts, or repo links.
I'm not talking testing tRPC procedures but unit testing components that use tRPC apis like this - api.upload_image.useMutation().
So far, I've got this - https://github.com/trpc/trpc/discussions/4899
But the problem I'm facing with this setup is that, while running tests, when I console log tRPC instance -
api or api.upload_image.useMutation, from my component, it returns [Function: noop] which is no-operation function that makes no request for msw to intercep. How do I mock this api to use my mocked tRPC instance createTRPCReact that I created to unit test react components.Thank you.
GitHub
I'm trying to test out react components which are using tRPC apis. I'm having a very difficult time trying to understand where I'm going wrong - thanks to the lib's author's ref...