Skip to content

Commit 3e3d405

Browse files
jeysalSimenB
authored andcommitted
docs: using Babel 6 with Jest 24 (#7677)
1 parent a551b19 commit 3e3d405

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

docs/GettingStarted.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,15 @@ To use [Babel](http://babeljs.io/), install the `babel-jest` and `@babel/core` p
8787
yarn add --dev babel-jest @babel/core
8888
```
8989

90-
Don't forget to add a [`babel.config.js`](https://babeljs.io/docs/en/config-files) file in your project's root folder. For example, if you are using ES6 and [React.js](https://reactjs.org) with the [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) and [`@babel/preset-react`](https://babeljs.io/docs/en/babel-preset-react) presets:
90+
Don't forget to add a [`babel.config.js`](https://babeljs.io/docs/en/config-files) file in your project's root folder. For example, if you are using ES2018 and [React](https://reactjs.org) with the [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) and [`@babel/preset-react`](https://babeljs.io/docs/en/babel-preset-react) presets:
9191

9292
```js
9393
module.exports = {
9494
presets: ['@babel/preset-env', '@babel/preset-react'],
9595
};
9696
```
9797

98-
You are now set up to use all ES6 features and React specific syntax.
99-
100-
```json
101-
{
102-
"presets": [["env", {"modules": false}], "react"],
103-
"env": {
104-
"test": {
105-
"presets": [["env"], "react"]
106-
}
107-
}
108-
}
109-
```
98+
You are now set up to use all ES2018 features and React-specific syntax.
11099

111100
> Note: `babel-jest` is automatically installed when installing Jest and will automatically transform files if a babel configuration exists in your project. To avoid this behavior, you can explicitly reset the `transform` configuration option:
112101
@@ -119,6 +108,21 @@ You are now set up to use all ES6 features and React specific syntax.
119108
}
120109
```
121110

111+
#### Babel 6
112+
113+
Jest 24 dropped support for Babel 6. We highly recommend you to upgrade to Babel 7, which is actively maintained. However, if you cannot upgrade to Babel 7, either keep using Jest 23 or upgrade to Jest 24 with `babel-jest` locked at version 23, like in the example below:
114+
115+
```
116+
"dependencies": {
117+
"babel-core": "^6.26.3",
118+
"babel-jest": "^23.6.0",
119+
"babel-preset-env": "^1.7.0",
120+
"jest": "^24.0.0"
121+
}
122+
```
123+
124+
While we generally recommend using the same version of every Jest package, this workaround will allow you to continue using the latest version of Jest with Babel 6 for now.
125+
122126
### Using webpack
123127

124128
Jest can be used in projects that use [webpack](https://webpack.github.io/) to manage assets, styles, and compilation. webpack does offer some unique challenges over other tools. Refer to the [webpack guide](Webpack.md) to get started.

0 commit comments

Comments
 (0)