T
TanStack3y ago
rare-sapphire

Vue useQuery and Vitest

Does any one have a snipet an example or a hint how do you go about testing a component that has a useQuery in it? Do we just mock the async function that the query is using?
No description
3 Replies
flat-fuchsia
flat-fuchsia3y ago
I'd like to know as well.
helpful-purple
helpful-purple3y ago
I like to use Mock Service Worker https://mswjs.io/ and have used it extensively with React Query. I'm planning to use it with Vue and Vitest soon too.
Mock Service Worker
Mock Service Worker
Seamless API mocking library for browser and Node.
helpful-purple
helpful-purple3y ago
It's nice to have the mocking layer be at a network level so all of your API middleware and handling is still tested.

Did you find this page helpful?