In my react application I have a function which is using keycloak instance like in code below
function fetchUrlWithAuthentication(url) {
const headers = new Headers();
headers.set('Authorization', `Bearer ${keycloakClient.token}`);
return fetch(url, {
headers,
});
}
in Jest file i'm getting error: keycloakClient is not defined
I tried to define in beforeEach keycloak instance but it didnt help, any suggestions how to fix this error ?
beforeEach(() => {
const keycloakClient = Keycloak({
url: 'https://www.test.de/auth',
realm: 'realm',
clientId: 'clientId',
});
originalOpen = window.open;
window.open = jest.fn().mockName('window.open');
});