-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue running with react hooks with tRPC 10.33.1+ #28
Comments
I found a better way of doing things that works with tRPC latest, I described it in trpc/trpc#5134 and closed that issue. Would you be interested in an integration test contribution that covers react hooks? |
Hi thanks for your work! So just to make sure, the problem is with setting global.fetch like https://github.com/c-ehrlich/msw-trpc-example this example is showing? Is this repo linked in the tRPC docs because I can't seem to find it?
That would be nice, also we could add something about that to the readme? |
Yes, setting global.fetch was the problem. Nope, the repo is just something I found while googling, I never found an official recommendation on how to test with hooks. My modified solution doesn't rely on setting global.fetch, but does still use the cross-fetch library. I'll go ahead and make a pull request to illustrate. |
Describe the bug
Starting at exactly version https://github.com/trpc/trpc/releases/tag/v10.33.1, the useQuery hook no longer testable with msw-trpc in vitest. For some reason the msw proxy server never receives a request. Possibly useQuery is not calling fetch, or not calling fetch in a way that msw is able to intercept.
I also reported this to tRPC: trpc/trpc#5134
I'm not sure if you can do anything to fix this, since my understanding is that msw-trpc only gets involved after msw's server receives a request.
As evidence that no request reaches the server, if I modify the test to have configuration like this, no error is thrown:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Test passes.
Test used to pass, this can be verified by pinning the tRPC versions to 10.33.0.
Versions
The text was updated successfully, but these errors were encountered: