I am setting up a test class for my auth service which usings oidc-client.
When attempting to mock the function signinRedirect of oidc-client, I am getting hoisting issues and the following error is being thrown. I understand the problem but don't know how to tackle it.
The module factory of ``jest.mock()`` is not allowed to reference any out-of-scope variables. Invalid variable access: myFunc
const myFunc = jest.fn();
jest.mock('oidc-client', () => ({
UserManager: () => ({
signinRedirect: myFunc
})
}));
describe('oAuth', () => {
it('should call signin redirect when login is called', () => {
login();
expect(myFunc).toHaveBeenCalled();
});
});