Skip to content

Commit

Permalink
Update custom "exports" conditions in Jest environment
Browse files Browse the repository at this point in the history
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 (react-native-community/cli#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 jestjs/jest#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
  • Loading branch information
huntie authored and OlimpiaZurek committed May 22, 2023
1 parent 378437b commit 3fb2d00
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions jest/react-native-env.js
Expand Up @@ -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'];
};

0 comments on commit 3fb2d00

Please sign in to comment.