Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
mock-async-storage
Advanced tools
Its a mock of react-native AsyncStorage for jest tests
npm install --save mock-async-storage
require('mock-async-storage')
This package is published with the following editions:
mock-async-storage/src/index.js
is Source + ESNext + Import + Flowmock-async-storage
aliases mock-async-storage/lib/index.js
mock-async-storage/lib/index.js
is Babel Compiled + ES2015 + RequireOlder environments may need Babel's Polyfill or something similar.
In your test codes:
const mockStorage = require('mock-async-storage');
// or import { mock, release } from 'mock-async-storage';
// mock();
// release();
// For mock AsyncStorage
mockStorage.mock();
// For unmock
mockStorage.release();
Working example:
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')
})
FAQs
Its a mock of react-native AsyncStorage for jest tests
The npm package mock-async-storage receives a total of 13,174 weekly downloads. As such, mock-async-storage popularity was classified as popular.
We found that mock-async-storage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.