Mock object of localStorage
.
Installation
npm install mock-localstorage
Usage
This library provide same interface as DOM Storage guide - Web developer guide | MDN.
var mockStorage = ;// Save data to the current session's storemockStorage;// Access some stored dataconsole;
Known Issue
Not support these spec.
localStorage#setItem
call toString()
I don't know this behavior.
;
dot access then convert to string.
Not support (please help)
localStorage"foo" = nulllocalStorage"foo";// "null"
Test
Test code is taken form w3c/web-platform-tests.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT