New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mocha-react-native

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-react-native

mocha-react-native

  • 0.6.0
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

mocha-react-native

This is a collection of helpers to get Mocha tests working nicely with React Native projects. It includes runtime babel transformations, aliasing imports and mocking modules.

How to use

$ npm install --save-dev mocha-react-native

Create a file in your project: test/mocha.opts

Paste the following into that file.

--compilers js:mocha-react-native/init

Advanced

Alias / Mock

You can add an alias or mock a react-native module to help with testing.

Create a file in your project: test/mocks.js

Add some code using addAlias and/or addMock:

import {addAlias, addMock} from 'mocha-react-native';

addAlias('react-native-linear-gradient', 'actual-empty-object');

addMock('exponent', {
  Font: {
    style: () => ({fontFamily: ''}),
  },
});

Tell mocha about that file by adding a line to test/mocha.opts:

--compilers js:mocha-react-native/init
--require ./test/mocks.js

Whitelist a react-native npm package

You can specify one ore more react-native npm packages that should be transformed by babel. This is done for you automatically if the package starts with react-native- however there are some packages that do not follow this convention and should be manually whitelisted.

Create a file in your project: test/whitelist.js

Use addPackage to whitelist packages by name:

import {addPackage} from 'mocha-react-native';

addPackage('react-clone-referenced-element');

Tell mocha about that file by adding a line to test/mocha.opts:

--compilers js:mocha-react-native/init
--require ./test/whitelist.js

License

This software is ICS licensed.

Keywords

FAQs

Package last updated on 10 Apr 2017

Did you know?

Socket

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.

Install

Related posts

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