Unable to resolve path to module 'react'. (import/no-unresolved) - reactjs

Seems like i am missing something here, it should work without errors but eslint keeps throwing the following:
Unable to resolve path to module 'react'. (import/no-unresolved)
Missing file extension for "react" (import/extensions)
when trying to import React from 'react'
here is some debug info:
package.json
{
"dependencies": {},
"devDependencies": {
"react": "16.3.2",
"react-dom": "16.3.2",
"#storybook/addon-actions": "^3.4.2",
"#storybook/addon-links": "^3.4.2",
"#storybook/addons": "^3.4.2",
"#storybook/react": "^3.4.2",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-runtime": "^6.26.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0"
}
}
.eslintrc
{
"parser": "babel-eslint",
"extends": ["airbnb", "prettier"],
"env": {
"browser": true,
"node": true,
"es6": true
}
}
.babelrc
{
"presets": ["env", "react"]
}
editor: atom v1.26.1
Thanks.

If you're using React Native it may help to add .native.js as an allowed extension in your .eslintrc file.
Also, if you're using Typescript then .ts and .tsx will help too.
"settings": {
"import/resolver": {
"node": {
"extensions": [".ts", ".tsx", ".native.js"]
}
}
}

I had some problem i removed nodo_modules directory from project and run yarn install / npm install

I think it complains because react should be in dependencies:
{
"dependencies": {
"react": "16.3.2",
"react-dom": "16.3.2",
},
"devDependencies": {
"#storybook/addon-actions": "^3.4.2",
"#storybook/addon-links": "^3.4.2",
"#storybook/addons": "^3.4.2",
"#storybook/react": "^3.4.2",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-runtime": "^6.26.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0"
}
}

I installed react and react-dom using npm i -E react react-dom trying to install the exact version which didn't install it correctly.
npm i react react-dom -D solved the problem.

This also happened to me. In my case, it was because I was running npm version 6, but a team member had installed a new library via npm version 7. Version 7 uses a new version for the lock file format.
Our solution was to make sure everyone was running the same npm version so that our package-lock.json files would be consistent.

Just comment out the import and run. Then again remove the comments. It worked for me.

try to add in eslintrc:
"rules": {
"import/no-unresolved": [2, { "devDependencies": true }],
...
}

I have experience with the same problem.
In my case, this error appear because I pull new update from the remote repository and it's bring new dependencies.
To solve this, I just install that dependencies with npm install

Related

NPM UNMET PEER DEPENDENCY questionmarks

Im using npm version 6.17.1
I have React 15.4.0 installed
I try and install npm install pretty-checkbox which gives me
+-- UNMET PEER DEPENDENCY popper.js#^1.16.0
+-- pretty-checkbox#3.0.3
`-- UNMET PEER DEPENDENCY react#15.4.0
I then try and install popper.js and get
+-- popper.js#1.16.0
`-- UNMET PEER DEPENDENCY react#15.4.0
So then I try and install react again. npm i react#15.4.0 and is then met with
`-- UNMET PEER DEPENDENCY react#15.4.0
So Im at a loss why and how this is suppose to work
Package.js
{
"private": true,
"scripts": {
"transport": "watchify js/app.js -v -t babelify -p livereactload -o public/js/bundle.js",
"ES6-to-ES5": "npx babel es6 --watch --presets babel-preset-env --out-dir js",
"watch": "gulp medicus-watch"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"bootstrap-sass": "^3.3.7",
"browserify": "^14.3.0",
"cross-env": "^3.2.3",
"del": "^2.2.2",
"fakerator": "^0.3.0",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-less": "^3.3.0",
"gulp-livereload": "^3.8.1",
"gulp-uglify": "^3.0.0",
"gulp-zip": "^4.0.0",
"laravel-elixir": "^5.0.0",
"laravel-mix": "0.*",
"livereactload": "^3.3.0",
"lodash": "^4.17.4",
"react-proxy": "^1.1.8",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vue": "^2.1.10",
"watchify": "^3.9.0"
},
"dependencies": {
"axios": "^0.15.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babelify": "^7.3.0",
"create-react-class": "^15.6.0",
"draft-js": "^0.11.4",
"draftjs-to-html": "0.9.1",
"fixed-data-table-2": "^0.7.17",
"jquery": "^3.2.1",
"moment": "^2.18.1",
"node-sass": "^4.5.3",
"pretty-checkbox": "^3.0.3",
"prop-types": "^15.5.10",
"ramda": "^0.23.0",
"react": "^15.4.0",
"react-bootstrap": "^0.31.0",
"react-bootstrap-datetimepicker": "0.0.22",
"react-dom": "^15.4.0",
"react-draft-wysiwyg": "^1.14.4",
"react-google-charts": "^1.5.5",
"react-native-html-to-pdf": "^0.8.0",
"react-radio-buttons": "^1.2.2",
"react-redux": "^4.3.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.2.2",
"react-sortable-hoc": "^0.6.8",
"react-widgets": "^3.4.8",
"redux": "^3.7.2",
"redux-form": "^6.8.0",
"redux-promise": "^0.5.3",
"redux-thunk": "^2.2.0"
},
"browserify": {
"transform": [
[
"babelify"
]
]
}
}
Package-lock.json
.
.
.
"react": {
"version": "15.4.0",
"resolved": "https://registry.npmjs.org/react/-/react-15.4.0.tgz",
"integrity": "sha1-c2wcfFQugIgScQbh9FCwEPhtFys=",
"requires": {
"fbjs": "^0.8.4",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.0"
}
},
.
.
.
I could see pretty-checkbox's developer last published 4 years ago.
Let's say the new module used popper-js#2.0 and someone who already had popper-js#4.0 as direct or sub-dependency in their project is more likely to face unmet peer dependency on using the new module.
Downgrading the version is not recommended due to possible conflict with other modules. A workaround would be to add resolutions.
Before doing anything, ensure there is no other version of react installed globally, delete your node-modules folder and package-lock.json file. Ensure your package.json dependency has react#15.4.0 and only add popperjs#^1.16.0 if you're sure that other modules in your project are not relying on later versions of popperjs.
Take a look at this article for a good explanation on peer dependencies
If there are other modules that needs other versions of popperjs then in your package.json you could add an additional property at the end like below,
{
.....,
"browserify": {
"transform": [
[
"babelify"
]
]
},
"resolutions": {
popperjs: "^1.16.0"
}
}
Note:- You're not removing the previous version, resolutions will just pin your sub-dependency to the specified version.
Good Read:- https://medium.com/learnwithrahul/understanding-npm-dependency-resolution-84a24180901b
I often try this when nothing makes sense:
Removing the node modules folder and Package-lock.json file.
Reset the package.json file to the last stable commit using git.
Then clear npm cache and run npm install.
And at the end try to install the package pretty-checkbox.

"React.createContext is not a function" - but I am not using it

I am getting "React.createContext is not a function" error while running a react-native application. I searched for 'createContent' in the code, it doesn't exist.
Any idea what may be the reason for the error.
It is an iOS build of an app that is already running on android.
Here is my package.json file:
{
"name": "newapp",
"version": "0.0.2",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest --verbose --coverage",
"test:update": "jest --verbose --coverage --updateSnapshot",
"test:watch": "jest --verbose --watch",
"coverage": "jest --verbose --coverage && xdg-open ./coverage/lcov-report/index.html",
"lint": "npx eslint --fix ./src/*"
},
"dependencies": {
"apollo-boost": "0.1.17",
"axios": "^0.18.0",
"babel": "^6.23.0",
"buffer": "5.1.0",
"cross-fetch": "^3.0.0",
"enzyme": "^3.3.0",
"graphql": "0.13.2",
"graphql-tag": "2.10.0",
"jasmine-react-helpers": "^0.2.2",
"lodash": "4.17.5",
"moment": "2.21.0",
"query-string": "^6.1.0",
"react": "16.2.0",
"react-addons-test-utils": "^15.6.2",
"react-apollo": "2.2.4",
"react-dom": "^16.4.0",
"react-native": "0.51.0",
"react-native-elements": "0.19.0",
"react-native-fabric": "^0.5.1",
"react-native-htmlview": "^0.12.1",
"react-native-link-preview": "^1.3.5",
"react-native-login": "^0.0.1-alpha.2",
"react-native-login-keycloak": "^1.0.2",
"react-native-onesignal": "3.2.6",
"react-native-push-notification": "https://github.com/Dhanraj-bidchat/react-native-push-notification.git",
"react-native-sleek-loading-indicator": "^0.1.3",
"react-native-spinkit": "^1.1.1",
"react-native-svg": "6.2.2",
"react-native-swipe-cards": "^0.1.1",
"react-native-swiper": "1.5.13",
"react-native-vector-icons": "4.5.0",
"react-navigation": "1.5.6",
"react-redux": "5.0.7",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-persist": "5.9.1",
"redux-thunk": "^2.2.0",
"victory-native": "0.17.2",
"whatwg-fetch": "2.0.4"
},
"devDependencies": {
"babel-eslint": "^8.2.3",
"babel-jest": "^22.4.4",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-preset-env": "^1.7.0",
"babel-preset-react-native": "4.0.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jest": "^21.17.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-only-warn": "^1.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.9.1",
"eslint-plugin-standard": "^3.1.0",
"jest": "^23.5.0",
"jest-resolve": "^23.0.0",
"jest-serializer-enzyme": "^1.0.0",
"react-native-mock-render": "^0.0.26",
"react-test-renderer": "^16.3.2",
"redux-mock-store": "^1.5.1",
"sinon": "^5.0.10"
},
"jest": {
"preset": "react-native",
"setupFiles": [
"./jest-setup.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"modulePaths": [
"<rootDir>/src",
"<rootDir>/node_modules"
],
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.jsx?$": "babel-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!(react-native-safe-area-view|react-navigation|react-native-htmlview|react-native-fabric|react-native-login|react-native-elements|react-native-vector-icons|react-native-spinkit|victory-pie|victory-chart|victory-core|react-native-svg|react-native|redux-persist|victory-native|react-native-swipe-cards|react-native-swiper)/)"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/assetsTransformer.js",
"\\.(css|less)$": "<rootDir>/assetsTransformer.js"
}
}
}
In your package react and react-dom are not having the same version which is why you get the error. react-dom#16.4.0 will want to have access to React.createContext but react#16.2.0 won't have it.
In order make it work run the following command:
yarn upgrade react#16.4.0
Or if you are using NPM:
npm install react#16.4.0
If this is happening using react 18 or Next JS 13. You are probably trying to use a client component functionalities in a server component. By default all components are treated as server components unless you explicitly specify.
To solve this and add the "use client" directive at the top of the file (before any imports). Here is more details on When to use Server vs. Client Components?
Try upgrading React to React to 16.4.1
Using npm I solved it by upgrading to 16.4.1:
npm i react#16.4.1
Adding #emotion/react resulted in a similar error TypeError: React.createContext is not a function. The error disappeared after I removed #emotion/react and downgraded #emotion/styled from 11 to 10.
run
npm install react#latest
and
npm install react-dom#latest
fixed my error with this update.
If npm i react#latest react-dom#latest doesn't work try doing npm update , it will update all packages.

JEST - unexpected token import while running test

Im writing tests for an application but i run into the following error when importing certain classes in my tests:
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/node_modules/react-redux/es/connect/connect.js:5
import connectAdvanced from '../components/connectAdvanced';
^^^^^^
SyntaxError: Unexpected token import
9 | children: PropTypes.string.isRequired,
10 | translator: PropTypes.func.isRequired
11 | };
| ^
I have not written any tests yet, i only imported the component in my test file:
import {TheComponent} from '../src/components/the-component';
My jest.config.json looks like this:
{
"moduleNameMapper": {
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy"
},
"setupFiles": [
"raf/polyfill",
"<rootDir>/test/testSetup.js"
]
}
My .babelrc file looks like this and is in the root directory:
{
"presets": [ "react", "es2015", "stage-2" ],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
]
}
My package.json file looks like this:
{
"name": "testError",
"version": "1.0.0",
"scripts": {
"test:jest": "jest --config=jest.config.json --watchAll"
},
"files": [
"dist",
"src"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.1",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"eslint": "^5.3.0",
"eslint-plugin-react": "^7.10.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^23.5.0",
"mkdirp": "^0.5.1",
"prettier": "^1.13.7",
"prettier-eslint": "^8.8.2",
"prop-types": "^15.6.0",
"react-test-renderer": "^16.5.0",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5",
"webpack-merge": "^4.1.4",
"yargs": "^12.0.1"
},
"dependencies": {
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"css-loader": "^1.0.0",
"eventing-bus": "^1.3.3",
"filesize": "^3.6.1",
"i18next": "^11.5",
"node-sass": "^4.8.3",
"react": "^16.4",
"react-circular-progressbar": "^1.0.0",
"react-dom": "^16.4",
"react-redux": "^5.0",
"react-truncate": "^2.4.0",
"redux": "^4.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.22.1"
},
"main": "dist/main.js",
"module": "src/index.js"
}
I have tried to put several values in both the transformIgnorePatterns and transform properties in .babelrc but so for no luck.
Does anyone know how i can solve this issue? Any help will be appreciated.
As Mitch commented above,
I added the following to my jest.config file and it worked: "transformIgnorePatterns": [ "node_modules/(?!(react-redux|lodash-es)/)" ]

How to use babel-jest to transpile tests

I'm writing tests for a React application and run into an issue while compiling classes that i import in my test files. When running the test suite
i get the following error:
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/node_modules/react-redux/es/connect/connect.js:5
import connectAdvanced from '../components/connectAdvanced';
^^^^^^
I have tried to use babel-jest to transpile using the transform property and the modulePathIgnorePatterns. My jest.config.json looks like:
{
"moduleNameMapper": {
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy"
},
"setupFiles": [
"raf/polyfill",
"<rootDir>/test/testSetup.js"
],
"transform": {
"^.+\\.jsx?$": "babel-jest"
}
}
my babel.rc file (its in the root directory)
{
"presets": [ "react", "es2015", "stage-2" ],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
]
}
I have the following packages in my package.json:
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.1",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"eslint": "^5.3.0",
"eslint-plugin-react": "^7.10.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^23.5.0",
"babel-jest": "^23.6.0"
"mkdirp": "^0.5.1",
"prettier": "^1.13.7",
"prettier-eslint": "^8.8.2",
"prop-types": "^15.6.0",
"react-test-renderer": "^16.5.0",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5",
"webpack-merge": "^4.1.4",
"yargs": "^12.0.1"
},
"dependencies": {
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"css-loader": "^1.0.0",
"eventing-bus": "^1.3.3",
"filesize": "^3.6.1",
"i18next": "^11.5",
"node-sass": "^4.8.3",
"react": "^16.4",
"react-circular-progressbar": "^1.0.0",
"react-dom": "^16.4",
"react-redux": "^5.0",
"react-truncate": "^2.4.0",
"redux": "^4.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.22.1"
}
Who knows how i can modify my jest.config or .babelrc file so that my tests will compile without problem? Thanks in advance.
Your problem is: js files from /node_modules are not compiled by default.
It is totaly fine when you run your code in browser (that is exactly why such modules are not compiled because you have no need for that).
But jest runs using Node which doesn't understand import syntax. The best solution is to enable babel transpilation of node_modules when you run tests.
{"env": {
"development": {
"plugins": ["transform-es2015-modules-commonjs"]
},
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
}}
Also use --no-cache when runing jest while fixing such problems.

Jest Test Babel Error: Plugin/Preset files are not allowed to export objects

I'm using a very up-to-date (December 2017) stack of dependencies. As I try-out isomorphic react tests with Jest, the test suit keeps failing with the following error:
* Test suite failed to run
[BABEL] /__tests__/router.test.js: Plugin/Preset files are not allowed to
export objects, only functions.
Here are my dependencies:
"dependencies": {
"axios": "^0.17.1",
"babel-polyfill": "^6.26.0",
"cors": "^2.8.4",
"express": "^4.16.2",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-router-dom": "^4.2.2"
},
"devDependencies": {
"#babel/core": "^7.0.0-beta.35",
"babel-cli": "^6.26.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.0.2",
"babel-jest": "^22.0.1",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"enzyme-to-json": "^3.2.2",
"eslint": "^4.11.0",
"eslint-plugin-react": "^7.5.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^21.2.1",
"nodemon": "^1.11.0",
"parallelshell": "^3.0.2",
"react-test-renderer": "^16.2.0",
"regenerator-runtime": "^0.11.1",
"supertest": "^3.0.0",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
},
"peerDependencies": {
"babel-core": "^7.0.0-0"
}
.babelrc :
{
"presets": [
"env",
"react",
]
}
Does anyone have any insights as to why Jest won't run?
{
"presets": [
"env",
"react"
],
"test": [
"jest"
]
}
Add the last block of code for "test" to you babel.rc
Here is my .babelrc code for reference
{
"presets": [
"env",
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
],
"test": [
"jest"
]
}
Here is my output from the command-line
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 9.264s
Ran all test suites.
Done in 12.99s.
babel bridge is meant to cover any issues between 6 and 7
That is 100% not what the bridge package does. All it does is allow tools that use babel-core to pass through to #babel/core. The entire package is this single line of code.
If you are using #babel/core, you need to use plugins that work on Babel 7. That means babel-preset-react should be changed to #babel/preset-react and same for #babel/preset-env and your .babelrc should be:
{
"presets": [
"#babel/env",
"#babel/react",
]
}
Similarly, babel-polyfill should be #babel/polyfill.
None of this is well documented yet because Babel 7 is still an unstable beta.
I met the same challenge while configuring jest to work with babel-6.
See complete explanation here
But in summary, this combination of --devDependencies worked for me, and i set-up babel-jest to transform my **.js files:
// package.json
"devDependencies": {
"babel-core": "6.26.0",
"babel-jest": "21.2.0",
"babel-loader": "7.1.2",
"babel-preset-env": "1.6.0",
"babel-preset-react": "6.24.1",
"babel-preset-stage-0": "6.24.1",
"jest": "21.2.1",
"webpack": "3.6.0"
},
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest"
}
}
// .babelrc
{
"presets": [
"env",
"stage-0",
"react"
]
}

Resources