From 3fb2d00639c4963861123f8de5d573613ae179e6 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 15 Mar 2023 17:18:08 -0700 Subject: [PATCH] Update custom "exports" conditions in Jest environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Updates the default set of `"exports"` condition names in our `ReactNativeEnv` for Jest, so that it aligns with the defaults in React Native CLI (https://github.com/react-native-community/cli/pull/1862). Also includes a subtle update to how this is accomplished. Instead of overriding `exportConditions()`, we assign to the underlying class property — this allows users (once https://github.com/facebook/jest/pull/13989 is merged) to override `customExportConditions` via [`testEnvironmentOptions`](https://jestjs.io/docs/configuration#testenvironmentoptions-object). ```js preset: 'react-native', testEnvironmentOptions: { customExportConditions: ['test', 'react-native'], }, ``` Changelog: [Internal] Reviewed By: jacdebug Differential Revision: D43879056 fbshipit-source-id: 86fffe2b5fdf9d8492d25b8b12a78be75b5fa3be --- jest/react-native-env.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jest/react-native-env.js b/jest/react-native-env.js index 624d3648766c33..c699a97d0df3a7 100644 --- a/jest/react-native-env.js +++ b/jest/react-native-env.js @@ -12,7 +12,5 @@ const NodeEnv = require('jest-environment-node').TestEnvironment; module.exports = class ReactNativeEnv extends NodeEnv { - exportConditions() { - return ['react-native']; - } + customExportConditions = ['import', 'require', 'react-native']; };