AdiA
Reactiflux5y ago
3 replies
Adi

Adi – 11-07 Jan 19

I am trying to mock getItem of localstorage but it is not returning null when I execute test why so?

jest
.spyOn(window.localStorage.proto, 'getItem')
.mockImplementation((key): any => {
if (key === 'sampleKey') {
return null;
}
});
Was this page helpful?