localStorage key "key" is reserved?
thisismydesign opened this issue · comments
Csaba Apagyi commented
Hey,
I was using key
and value
dummy strings and it took me a while to figure out that key
behaves differently in jest-localstorage-mock
than other random strings:
console.log(localStorage.getItem("bla"));
console.log src/utils/ReactApp/ReactAppUtils.js:13
null
console.log(localStorage.getItem("key"));
console.log src/utils/ReactApp/ReactAppUtils.js:12
{ [Function: mockConstructor]
_isMockFunction: true,
getMockImplementation: [Function],
mock: [Getter/Setter],
mockClear: [Function],
mockReset: [Function],
mockRestore: [Function],
mockReturnValueOnce: [Function],
mockResolvedValueOnce: [Function],
mockRejectedValueOnce: [Function],
mockReturnValue: [Function],
mockResolvedValue: [Function],
mockRejectedValue: [Function],
mockImplementationOnce: [Function],
mockImplementation: [Function],
mockReturnThis: [Function],
mockName: [Function],
getMockName: [Function] }
While in my browser:
console.log(localStorage.getItem("key"));
// => null
I think this is pretty misleading. Perhaps it could be fixed or menioned in the readme?
Bryan Clark commented
I believe this is because we haven't fixed #66 jump in there if you know a solution.
Csaba Apagyi commented
I see. Why close this though if this is an actual issue?
Bryan Clark commented
Ah, wrong button.