Adi
Adi3y ago

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; } }); ‘’’
4 Replies
ScriptyChris
ScriptyChris3y ago
window.localStorage.proto is non-existing property. You rather meant window.localStorage.prototype
Adi
Adi3y ago
Ok got it thanks a lot
ScriptyChris
ScriptyChris3y ago
you can react to the answer with ✅ to mark thread as solved
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/933316706057736192