I have the following method that creates and returns an instance of the Apollo React Client:
export default function createGraphQlClient(url: string) {
return new ApolloClient({
cache: new InMemoryCache(),
connectToDevTools: true,
link: ApolloLink.from([
new HttpLink({
uri: url,
credentials: 'include',
}),
onError(({ graphQLErrors, networkError }) => {
sendError(url, graphQLErrors, networkError);
}),
]),
});
}
In my Jest test file for this function, I’d like to trigger the onError
callback function that’s passed in above. How do I go about doing this?