Skip to content
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

Request: Example integration with Next and RTL #24

Open
PupoSDC opened this issue Aug 12, 2023 · 0 comments
Open

Request: Example integration with Next and RTL #24

PupoSDC opened this issue Aug 12, 2023 · 0 comments

Comments

@PupoSDC
Copy link

PupoSDC commented Aug 12, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant