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?

3 Replies
rare-sapphire•3y ago
I'd like to know as well.
conscious-sapphire•3y 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.
conscious-sapphire•3y 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.