localstorage-mock
v1.0.2
Published
A mock implementation of localStorage for testing.
Maintainers
Readme
localstorage-mock
A mock implementation of Window.localStorage.
Usage
- Install package:
npm i localstorage-mock --save-dev
- Import / require module:
import 'localstorage-mock'orrequire('localstorage-mock')
Mock should now be accessible globally as localStorage.
API
getItem(key)- get item by keysetItem(key, value)- insert new itemclear()- clear storagelength- number of items in storage
Note: I realise there are already packages out there which implement local storage. I wrote this simply as a fun exercise in publishing my first npm module.
