TRPC Testing Wrapper - Unit Testing components that contain a query (Not testing the query it self)
This is my wrapper
When ever i use it i get a
httpBatchLink
no fetch implementation error.
Can anyone help?
my test
6 Replies
my current implementation is trying to call a function in the component but there is no context for it in my test i'm guessing, this is since removing the wrapper.
reference from trpc: https://github.com/WeirdoGit/NewGitRepo/blob/162cd9317c0e978ea2e666488a133838859cd50b/packages/server/test/react.test.tsx#L337
GitHub
NewGitRepo/react.test.tsx at 162cd9317c0e978ea2e666488a133838859cd5...
Contribute to WeirdoGit/NewGitRepo development by creating an account on GitHub.
Thank you this is was the final solution
Thanks for documenting your journey setting up testing with trpc. This really helped me get oriented although I eventually went for a similar solution shown here: https://github.com/mthomps4/trpc-next-auth-spike/blob/ae259ca5d1e09fce206d8a7e985646ad16c46a37/tests/utils.tsx
GitHub
trpc-next-auth-spike/utils.tsx at ae259ca5d1e09fce206d8a7e985646ad1...
trpc-next-auth-spike. Contribute to mthomps4/trpc-next-auth-spike development by creating an account on GitHub.
Leaving this here for my future self and anyone else how may run into this issue as well.
Also includes setup/config for cypress testing as well.
For posterity I also came across a few other useful examples which I think it's worth documenting here:
Simple example with mocking the session and router:
https://github.com/ziadsabillah/eduPlatform/blob/f2e5345e136e0c69eab843289f0a47c021d4a3df/src/tests/login.test.tsx
GitHub
eduPlatform/login.test.tsx at f2e5345e136e0c69eab843289f0a47c021d4a...
Contribute to ziadsabillah/eduPlatform development by creating an account on GitHub.