Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react qurery jest test mock queryClientProvider

const queryClient = new QueryClient();
2 const wrapper = ({ children }) => (
3   <QueryClientProvider client={queryClient}>
4     {children}
5   </QueryClientProvider>
6 );
7 
8 const { result, waitFor } = renderHook(() => useCustomHook(), { wrapper });
9 
10 await waitFor(() => result.current.isSuccess);
11 
12 expect(result.current.data).toEqual("Hello");
Source by react-query.tanstack.com #
 
PREVIOUS NEXT
Tagged: #react #qurery #jest #test #mock #queryClientProvider
ADD COMMENT
Topic
Name
9+3 =