T
TanStack3y ago
flat-fuchsia

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
rare-sapphire
rare-sapphire3y ago
I'd like to know as well.
conscious-sapphire
conscious-sapphire3y 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.
conscious-sapphire
conscious-sapphire3y 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?