getItem() bug
Katarn opened this issue · comments
Katarn commented
I seem to have found the wrong work of getItem()
method. Try this code in browser console and mock:
localStorage.setItem("param", 1);
typeof JSON.parse(localStorage.getItem("param")); // "number" in Chrome and "string" in this mock
It not bug in JSON.parse()
method because I also tested typeof JSON.parse("1")
in Node and it was "number"
.
Bryan Clark commented
This likely comes from out setItem
method that appends a string. https://github.com/clarkbw/jest-localstorage-mock/blob/master/src/localstorage.js