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
adverse-sapphireOP•9mo ago
Specifically this means mocking isPending, not isFetching
other-emerald•9mo 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 rejectsadverse-sapphireOP•9mo ago
Yeah, maybe setQueryDefaults([..keys], {}), instead?
I kind of want to avoid passing in mock params, so I can work with integration tests too.