For test purposes I need to mock jwt-decode library. I use it as follows:
const decodedToken: { exp: number } = jwt_decode(token);
And then in tests tried the following and got errors like below:
jest.mock('jwt-decode');
TypeError: Cannot read property 'exp' of undefined
jest.mock('jwt-decode', () => ({
exp: 123,
}));
TypeError: (0 , _jwtDecode.default) is not a function
Aucun commentaire:
Enregistrer un commentaire