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; } }); ‘’’
S
ScriptyChris820d ago
window.localStorage.proto is non-existing property. You rather meant window.localStorage.prototype
A
Adi820d ago
Ok got it thanks a lot
S
ScriptyChris820d ago
you can react to the answer with ✅ to mark thread as solved
UU
Unknown User819d ago