Request: Example integration with Next and RTL
PupoSDC opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
I would like to request a demo of a next-trpc combined with this project and RTL. Ideally Running in vite.
Describe the solution you'd like
I've set up my project in such a way I would expect things to work. I've wired up this project with storybook-msw
. Code,
The trpc
client is created with createTRPCNext
here. This client is provided to the stories here.
Now I want to write tests for these stories. Code
The problem is that those mocks never resolve. they are in place, I can see them with server.listHandlers
, and if i manually fire a query like fetch("/api/trpc/questions....")
the interceptor works. But on the queries triggered by the trpc
client, the query never resolves. It doesn't trigger the interceptor, it doesn't trigger the onUnhandledRequest
, but if i remove the msw
mock, and spy on fetch
i can see the query being done.
I've spent quite some time trying to dig into what it's wrong, but this goes beyond me. Plenty of people seem to have no problem integrating this project in RTL, but they are all using the raw react approach. There is even this thread that partially explains a workaround... but I couldn't get it working for my project.
I would like to have a demo that demonstrates how this setup, or a similar one is possible. My project is quite complicated, but if you want I can try to provide a minimal reproduction with the key functionalities.
Describe alternatives you've considered
- use
cross-fetch
... no effect - remove
msw-storybook
no effect. - Apply the workaround from here but in my code it was just not practicable.
Additional context
Thanks a lot for this project!