/mock-async-storage

Mock AsyncStorage for react-native jest unit tests

Primary LanguageJavaScriptMIT LicenseMIT

Jest Mock AsyncStorage for react-native

Travis CI Build Status

Standard - JavaScript Style Guide

Its a mock of react-native AsyncStorage for jest tests

Install

NPM

  • Install: npm install --save mock-async-storage
  • Module: require('mock-async-storage')

This package is published with the following editions:

  • mock-async-storage/src/index.js is Source + ESNext + Import + Flow
  • mock-async-storage aliases mock-async-storage/lib/index.js
  • mock-async-storage/lib/index.js is Babel Compiled + ES2015 + Require

Older environments may need Babel's Polyfill or something similar.

Usage

In your test codes:

const mockStorage = require('mock-async-storage');
// or import { mock, release } from 'mock-async-storage/src';
// mock();
// release();

// For mock AsyncStorage
mockStorage.mock();

// For unmock
mockStorage.release();