DEV Community

Discussion on: Testing custom Apollo hooks with React Testing Library

Collapse
 
hugoliconv profile image
Hugo • Edited

I created this hook because I was using the query all over the place and in my case, I know that both the query and the input to the custom hook won't change. The only thing that could change is the queryOptions, maybe I want to change the fetchPolicy option or add a callback when the request is completed using the onCompleted option. But as I said, that is the only thing that could change.

const { loading, error, countries } = useCountries({
  fetchPolicy: "network-only"
});
//...
const { loading, error, countries } = useCountries({
  onCompleted: () => alert("completed")
});