This error occurs when I attempt to test my React native code with Jest
The error code suggests the following steps, and I've tried both suggestions to no avail.
"Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation. If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing."
Here are my config files:
//babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo','@babel/preset-env','@babel/preset-react'],
plugins: ['react-native-reanimated/plugin','@babel/plugin-syntax-jsx']
};
};
//.babelrc
{
"plugins": [
"module:react-native-dotenv",
"@babel/plugin-syntax-jsx"
],
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
//package.json
"dependencies":
{
...
"react": "17.0.1",
"react-native": "^0.64.3",
...
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/plugin-syntax-jsx": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@redux-devtools/core": "^3.11.0",
"@testing-library/react-native": "^9.1.0",
"@types/react-native": "~0.64.12",
"babel-jest": "^27.5.1",
"jest": "^26.6.3",
"mockdate": "^3.0.5",
"react-native-debugger": "^1.1.0",
"react-test-renderer": "^18.0.0",
"redux-devtools-extension": "^2.13.9",
"remote-redux-devtools": "^0.5.16",
"typescript": "~4.3.5"
},