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
window.localStorage.proto
is non-existing property. You rather meant window.localStorage.prototype
Ok got it thanks a lot
you can react to the answer with ✅ to mark thread as solved
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