Include warning that this package is potentially duplicative for anyone using Jest 24 and above
dgirgenti opened this issue · comments
It has come to our attention (through trial and error) that this package is no longer needed for users of Jest 24 or later. jest@24.x.x
ultimately includes jsdom
, of which a recent version added localStorage
and sessionStorage
support out of the box.
I think it would be worth calling this out somewhere in the docs of jest-localstorage-mock
as it can lead to unnecessary package bloat.
@dgirgenti and I'm guessing you had to write your own spies around the methods on window
?
@dgirgenti and I'm guessing you had to write your own spies around the methods on
window
?
I guess, like me, @dgirgenti doesn't use the mocking/spying ability of this library.
function setSomethingInLocalStorage(value) {
localStorage.setItem('something', value);
}
which in my simple use-case can be tested as:
it('sets something in localStorage', () => {
setSomethingInLocalStorage('foo')
expect(localStorage.getItem('something')).toEqual('foo')
})
That is jest 26 without the jest-localstorage-mock
library.
Like @dgirgenti I discovered this through trial and error. Which is why I +1 this request.