I am mocking localStorage in unitests like
function storageMock() {
var storage = {};
....
}
and setting localStorage like
window.localStorage = localStorageMock()
It was working fine until, I have updated Node to 10.15.1
.
It is throwing error that TypeError: Cannot set property localStorage of #<Window> which has only a getter
.
Any idea that how I can mock localStorage and set it to window.localStorage.
P.S I am getting answers like setItem
and getItem
on localStorage, is there any way that I can set whole localStorage at once.