For testing purposes I need to mock jwt-decode function but none of the suggestions I've found here helped. The code were jwtDecode is used looks like this
import jwtDecode from 'jwt-decode';
...
const { exp } = jwtDecode(accessToken);
And inside the test I need to mock this returned exp
value. I've tried mocking it as per suggestion found in Mock jwt-decode in Jest
jest.mock('jwt-decode', () => () => ({ exp: 123456 }));
const { exp } = jwtDecode('123456');
But that returns
InvalidTokenError: Invalid token specified: Cannot read property 'replace' of undefined