Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mock-async-storage

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-async-storage - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.vscode/settings.json

2

package.json
{
"name": "mock-async-storage",
"title": "Jest Mock AsyncStorage for react-native",
"version": "1.0.1",
"version": "1.0.2",
"description": "Its a mock of react-native AsyncStorage for jest tests",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -52,3 +52,3 @@ <!-- TITLE/ -->

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

@@ -63,1 +63,29 @@ // release();

```
Working example:
```JavaScript
import 'react-native';
import { mock, release } from 'mock-async-storage'
import React from 'react';
import Index from '../index.android.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
mock()
import { AsyncStorage as storage } from 'react-native'
it('renders correctly', () => {
const tree = renderer.create(
<Index />
);
});
it('Mock Async Storage working', async () => {
await storage.setItem('myKey', 'myValue')
const value = await storage.getItem('myKey')
expect(value).toBe('myValue')
})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc