1.0.2 • Published 6 years ago

@tomekf/storage-mock v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

storage-mock

localStorage (and sessionStorage) mock for Jest and other tools

Notice

Uses Proxy

Instalation

npm i @tomekf/storage-mock # or yarn add @tomekf/storage-mock

Usage

"Normal"

import StorageMock from '@tomekf/storage-mock';

global.localStorage = new StorageMock();
global.sessionStorage = new StorageMock('sessionStorage');

const myStorage = newStorage('yolo');

AutoMock ;)

import '@tomekf/storage-mock/dist/auto';

Arguments

name - (optional) name for debugging, __NAME__ prop in StorageMock instance

Methods

Normal localStorage and sessionStorage methods plus extra ones (consult src/index.js & src/index.test.js).

Test

git clone git@github.com:tomek-f/storage-mock.git
cd ./storage-mock
npm i # or yarn
npm test # or yarn test
npm run eslint-src # or yarn (run) eslint-src

ES5, ES, UMD (CommonJS, AMD, global)

"Normal" modules

  • ES5 commonJs @tomekf/storage-mock or @tomekf/storage-mock/dist
  • ES6+ @tomekf/storage-mock/src
  • UMD @tomekf/storage-mock/dist/umd (global: window.StorageMockTF)

AutoMock modules

  • ES5 commonJs @tomekf/storage-mock/dist/auto
  • ES6+ @tomekf/storage-mock/src/auto
  • UMD @tomekf/storage-mock/dist/auto-umd (no global)

Changelog

View on github.

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.0

6 years ago