Default to React Native Jest Preprocessor
See original GitHub issue🚀 Feature Proposal
If using the react-native
preset, the transformer should default to the react-native/jest/preprocessor.js
. If left off, it doesn’t transform anything. And React Native defaults to its own transformer so adding an extra babel.config.js
just for tests seems redundant when all the pieces are already there.
Motivation
One less package (metro-jest-babel-resolver
or something like that) and one less config file for default RN projects (babel.config.js
)
Example
The only thing you need to get a simple RN project up and running in Jest should be:
{
preset: "react-native"
}
Currently, you need this extra line:
"preset": "react-native",
"transform": {
"\\.(js|ts|tsx)$": "./node_modules/react-native/jest/preprocessor.js"
},
Pitch
Makes the requirements to use Jest for React Native even smaller and more concise.
Issue Analytics
- State:
- Created 3 years ago
- Comments:21
Top Results From Across the Web
Using with React Native | ts-jest - GitHub Pages
To use ts-jest with React Native + TypeScript and Babel 7, you'll first need ... const { defaults: tsjPreset } = require('ts-jest/presets')
Read more >React Native with Typescript and Jest is broken after 0.57 ...
If I use "presets": ["module:metro-react-native-babel-preset"] then tests are broken but production/development is working. Not sure why it's ...
Read more >Configuring Jest
The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >How to use the ts-jest/presets.defaults.transform function in ts ...
To help you get started, we've selected a few ts-jest/presets.defaults.transform examples, based on popular ways it is used in public projects.
Read more >Using TypeScript With React Native - Jan Hesters
Jest is already installed by default . We do need to install ts-jest, though. npm install --save-dev ts-jest.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Should be fixed now: #10910
You need to build jest first. Run
yarn build:js
in root, then you should be able to run the example.This is covered by the contribution guide, fwiw