Socket
Book a DemoInstallSign in
Socket

@rnx-kit/jest-preset

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rnx-kit/jest-preset

Jest preset for React Native code bases

0.2.1
Source
npmnpm
Version published
Weekly downloads
3.1K
-39.41%
Maintainers
7
Weekly downloads
 
Created
Source

@rnx-kit/jest-preset

Build npm version

A Jest preset with support for React Native platform-specific extensions and TypeScript.

Usage

In a TypeScript-only Package (Non-React Native)

Add preset: "@rnx-kit/jest-preset" to your Jest config:

 module.exports = {
+  preset: "@rnx-kit/jest-preset",
   ...
 };

@rnx-kit/jest-preset will detect that you're not targeting React Native and exclude any React Native specific configurations.

In a React Native Package

There are three ways to use this preset when targeting React Native, depending on your personal preference.

Single jest.config.js

If you prefer to use a single Jest config, you can provide the target platform via an environment variable. First, add preset: "@rnx-kit/jest-preset" to your Jest config:

 module.exports = {
+  preset: "@rnx-kit/jest-preset",
   ...
 };

Then specify the target platform when running Jest:

RN_TARGET_PLATFORM=ios npm run jest

Multiple jest.config.js

Alternatively, you can have a Jest config file for each platform, e.g.:

// jest.config.ios.js
module.exports = require("@rnx-kit/jest-preset")("ios", {
  ...
});

Then specify the config file to use when running Jest:

npm run jest --config jest.config.ios.js

Use @rnx-kit/cli

You can specify the target platform using the rnx-test command provided by @rnx-kit/cli. First, add preset: "@rnx-kit/jest-preset" to your Jest config:

 module.exports = {
+  preset: "@rnx-kit/jest-preset",
   ...
 };

Then specify the target platform when running rnx-test:

npm run react-native rnx-test --platform ios

In an Out-of-Tree Platform Package

Add preset: "@rnx-kit/jest-preset" to your Jest config:

 module.exports = {
+  preset: "@rnx-kit/jest-preset",
   ...
 };

The target platform will be deduced by reading react-native.config.js at the package root.

FAQs

Package last updated on 03 Dec 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.