maloguertin / msw-trpc

tPRC support for MSW
208 stars 21 forks source link

Adding an integration test for query hooks. #30

Open tarehart opened 11 months ago

tarehart commented 11 months ago

Closes #

🎯 Changes

This adds a description in the README for how to mock useQuery hooks from @trpc/react-query, and an integration test to verify.

I also updated the package lock, the @trpc/* dependencies had been stuck on 10.9.0 for a long time. Now they'll end up being 10.44.0 for fresh installs of msw-trpc.

This is related to the issue https://github.com/maloguertin/msw-trpc/issues/28

✅ Checklist

tarehart commented 11 months ago

Thinking more about it, I think I was unwise with the way I bumped the dependency. Should be something like > 10.9 and < 11. I'll update

Edit: done

maloguertin commented 11 months ago

I'm not against this PR at all but it is still unclear to me if the bug that is reported in the issue is reproducible and what it is related to. I think that if it is specifically related to vitest + trpc 10.33.1 we should maybe just add this as a troubleshoot section in the doc instead.

tarehart commented 11 months ago

Yes, the bug is reproducible by taking the code in this PR and commenting out import 'whatwg-fetch' in setup.ts.

I no longer think it's related to vitest, but I'm confident that trpc 10.33.1 began the need for some kind of fetch polyfill. I haven't taken the time to truly find the root cause.

I don't mind if this goes in a troubleshooting section, but I think it's valuable in the 'usage' section because it advertises that msw-trpc works with @trpc/react-query, and it might help people avoid the pitfall in the first place.

Maybe I could modify the integration test to be more self-contained / self-explanatory, and make the README link to it as an example?

maloguertin commented 3 months ago

@tarehart sorry for the really long delay, this is a fine PR, I will merge it :)

if you could fix the conflicts I'd appreciate it.