How to mock loading/error states.
In storybook I'm using setQueryData to set mock data. How can I manually set loading/error states?
3 Replies
national-goldOP•12mo ago
Specifically this means mocking isPending, not isFetching
genetic-orange•12mo ago
I'd go with mocking the queryFn and not using setQueryData
Because I think once you setQueryData,
sucess will always be true
so for isPending have a queryFn that never resolves, for isError, have a promise that immedially rejectsnational-goldOP•12mo ago
Yeah, maybe setQueryDefaults([..keys], {}), instead?
I kind of want to avoid passing in mock params, so I can work with integration tests too.