Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a unit testable localStorage mock
const fakeWindowLocalStorage = {
localStorage: {
data: {},
length: 0,
setItem(name, value) {[name] = value.toString();
this.length = Object.keys(;
getItem(name) {
removeItem(name) {
this.length = Object.keys(;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.