question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using preset 'react-native' for Jest breaks .babelrc usage in monorepo

See original GitHub issue

Description

I have a monorepo where there is a babel.config.js in the root and I want to have a .babelrc in the package that has react-native. Previously, I had a babel.config.js in that package. I noticed that if I comment out preset: 'react-native' in my jest.config.js, the .babelrc DOES get read, but obviously throws a bunch of errors because the preset sets up a bunch of mocks. I don’t see anything in the jest setup file the preset uses that specifically skips a .babelrc.

I am following https://babeljs.io/docs/en/config-files#root-babelconfigjson-file and https://babeljs.io/docs/en/config-files#subpackage-babelrcjson-files.

Version

0.67.4

Output of npx react-native info

System: OS: macOS 12.3.1 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 154.58 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.0 - /private/var/folders/93/1k48nb2j093b_cfpbcf6cq1n4c68j2/T/xfs-050c6f0a/node Yarn: 3.0.2 - /private/var/folders/93/1k48nb2j093b_cfpbcf6cq1n4c68j2/T/xfs-050c6f0a/yarn npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm Watchman: 2021.10.18.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/eliw00d/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Set up a monorepo with a mobile package that used npx react-native init to set it up. Add a jest.config.js with preset react-native. Rename the babel.config.js to .babelrc.js and add a babel.config.js to monorepo root. Add babelrcRoots to babel.config.js and try running tests. See repro for all of this.

Snack, code example, screenshot, or link to a repository

https://github.com/eliw00d/react-native-jest-babelrc-repro

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cipolleschicommented, May 18, 2022

Hi @eliw00d. The label only indicates that the Issue has been opened targeting the Old Architecture (0.67.4).

The new architecture support starts to version 0.68. We are also releasing some improvements to the setup of babel.

I’m not sure whether the improvement may be solve your issues, but I would try to update to 0.68 and see what happens.

0reactions
github-actions[bot]commented, Nov 22, 2022

This issue was closed because it has been stalled for 7 days with no activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest TransformIgnorePatterns all node_modules for React ...
I want to Ignore All Node modules by TransformIgnorePattern, but seems it is not Working for my React-Native Preset,.. Looking for the Helpful ......
Read more >
Using with React Native | ts-jest - GitHub Pages
To use ts-jest with React Native + TypeScript and Babel 7, you'll first need to ... presets: ['module:metro-react-native-babel-preset'],
Read more >
Monorepo setup with Lerna, TypeScript, Babel 7 and other
In this article we'll cover lerna approach with yarn as package manager. Moreover, lerna integrates so greatly with yarn workspaces as it allows ......
Read more >
babel-jest | Yarn - Package Manager
0 vulnerabilities. Jest plugin to use babel for transformation. ... [jest-config] Do not warn about preset in ProjectConfig #13583 ...
Read more >
React Native monorepo for every platform: Android & iOS
Once you've updated the nohoist list, run yarn reset && yarn from the project root to re-install the dependencies using the updated settings....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found