JSPM

  • Created
  • Published
  • Downloads 343250
  • Score
    100M100P100Q179745F
  • License ISC

Mock localstorage in your Jest tests

Package Exports

  • jest-localstorage-mock

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jest-localstorage-mock) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm | npm | Twitter ---|---

Greenkeeper badge

Install

For yarn:

yarn add --dev jest-localstorage-mock

For npm:

npm i --save-dev jest-localstorage-mock

Setup

Require module directly

In your package.json under the jest section add the setupFiles attribute with this module name.

"jest": {
  "setupFiles": [
    "jest-localstorage-mock"
  ]
}

Use setup file

Alternatively you can create a new setup file and require this module.

__setups__/localstorage.js

global.chrome = require('jest-localstorage-mock');

And add that file to your setupFiles:

"jest": {
  "setupFiles": [
    "./__setups__/localstorage.js"
  ]
}

Usage

With this module setup in Jest you can run your web tests that rely on localstorage without fail.

Development

yarn install
yarn test

Pull Request

Before every PR run the following:

yarn run prettier

Publish

When publishing a new build, run the following:

yarn run prettier
yarn run build
yarn publish