🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@moxy/jest-config-react-native

Package Overview
Dependencies
Maintainers
15
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moxy/jest-config-react-native

MOXY's Jest configuration enhancer for React Native apps

latest
Source
npmnpm
Version
6.1.0
Version published
Weekly downloads
6
Maintainers
15
Weekly downloads
 
Created
Source

jest-config-react-native

NPM version Downloads Dependency status Dev Dependency status

MOXY's Jest configuration enhancer for React Native apps.

⚠️ This enhancer requires you to have react-native installed in your project.

Installation

$ npm install --save-dev jest @moxy/jest-config-base @moxy/jest-config-react-native

This package should be used in conjunction with @moxy/jest-config-base.

What's included?

  • React Native Jest preset: Adds react-native/jest-preset to configure the environment.
  • Transform: Allows importing common files used in React Native projects, such as fonts, images and videos.
  • React Native mocks: Supress warnings and errors when trying to access native functionality.

Usage

To use this enhancer, use the compose function that comes with this package. Keep in mind, the first item should always be the base configuration!

'use strict';

const { compose, baseConfig } = require('@moxy/jest-config-base');
const withReactNative = require('@moxy/jest-config-react-native');

module.exports = compose(
    baseConfig('node'),
    withReactNative(),
);

The enhancer accepts an options object as the first argument with the following keys:

  • transformModules: A function that allows you to add (or remove) modules to be transformed by Babel. It has the following signature (patterns) => newPatterns, where the default patterns are ['(jest-)?react-native(-.*)?/', '@react-native-community/'].

To showcase the usefulness of transformModules, let's pretend that you use React Navigation in your project. You would need to compile its packages to make them work in Jest, so you would add them to transformModules like so:

'use strict';

const { compose, baseConfig } = require('@moxy/jest-config');
const withReactNative = require('@moxy/jest-config-react-native');

module.exports = compose(
    baseConfig('node'),
    withReactNative({
        transformModules: (patterns) => [...patterns, '@react-navigation/'],
    }),
);

Keywords

jest-config

FAQs

Package last updated on 24 Jun 2021

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