clarkbw / jest-localstorage-mock

A module to mock window.localStorage and window.sessionStorage in Jest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

localStorage key "key" is reserved?

thisismydesign opened this issue · comments

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?

I believe this is because we haven't fixed #66 jump in there if you know a solution.

I see. Why close this though if this is an actual issue?

Ah, wrong button.