I have an application which uses an Auth0Provider that is set up like so:
export function AuthProvider({ children }: Props) {
return (
<Auth0Provider
domain={process.env.REACT_APP_AUTH0_DOMAIN as string}
clientId={process.env.REACT_APP_AUTH0_CLIENT_ID as string}
redirectUri={window.location.origin}
>
<Auth0ApolloProvider>{children}</Auth0ApolloProvider>
</Auth0Provider>
);
}
export function Auth0ApolloProvider({ children }: Props) {
const { getAccessTokenSilently } = useAuth0();
const authMiddleware = setContext(async (_, { headers, ...context }) => {
try {
const token = await getAccessTokenSilently({
audience: "background-api",
});
return {
headers: {
...headers,
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
...context,
};
} catch (error) {
console.log(error);
return { headers, ...context };
}
});
const client = new ApolloClient({
...
});
return <ApolloProvider client={client}>{children}</ApolloProvider>;
}
I am importing AuthProvider
into my tests and wrapping them within it in order to simulate all API call data within my tests.
When I do npm run test
, then I get: TypeError: da(...).digest is not a function
coming from the try / catch
here is a screenshot of some additional terminal output: