How to mock refetch in jest with typescript
Hello! I have a custom hook that calls
useQuery and exports its refetch property. How could I mock this in jest? its definition is <TPageData>(options?: RefetchOptions & RefetchQueryFilters<TPageData>) => Promise<QueryObserverResult<TData, TError>> , which means the return type itself has a refetch so not sure how to handle the recursion.2 Replies
rival-blackOP•3y ago
for context, I am mocking the return values of this custom hook, and the only type i'm having issues with is this.
I guess the alternative to this would be to mock
useQuery itself and all the other hooks this hook makes use of.foreign-sapphire•3y ago
I always recommended to only mock the network layer and nothing else