Skip to content

Commit

Permalink
Don't register Babel in Jest preprocessor (#36522)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #36522

We don't need to register Babel for internal tests, Jest takes care of hooking require. This resolves an internal require-clobbering issue.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D44197281

fbshipit-source-id: ee076d431b0c49ae4a2da609d964cdd66bca27f8
  • Loading branch information
robhogan authored and facebook-github-bot committed Mar 18, 2023
1 parent 4a05f68 commit e5b97f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-native/jest/private/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const nodeFiles = new RegExp(
'/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc.
].join('|'),
);
const nodeOptions = babelRegisterOnly.config([nodeFiles]);

babelRegisterOnly([]);
// Use metro-babel-register to build the Babel configuration we need for Node
// files, but Jest takes care of hooking require so we don't actually register
// Babel here.
const nodeOptions = babelRegisterOnly.config([nodeFiles]);

const transformer = require('metro-react-native-babel-transformer');
module.exports = {
Expand Down

0 comments on commit e5b97f0

Please sign in to comment.