I want to test this customHook but it's showing me an error of waitFor is not a function.
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { renderHook } from "@testing-library/react";
import { useCustomHookForTestCase } from "../useQueryCustomHook";
const queryClient = new QueryClient();
// jest.mock('../../../Utilies/Apicall')
describe('Testing custom hooks of react query', () => {
const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
);
it('Should get data of todos from api',async () => {
const { result, waitFor } = await renderHook(() => useCustomHookForTestCase(), { wrapper });
await waitFor(() => result.current.isSuccess );
expect(result.current.data).toEqual("Hello");
})
})
export function useCustomHookForTestCase() {
return useQuery(['customHook'], () => 'Hello');
}