1 | # babel-jest
|
2 |
|
3 | [Babel](https://github.com/babel/babel) [jest](https://github.com/facebook/jest)
|
4 | plugin
|
5 |
|
6 | ## Usage
|
7 |
|
8 | If you are already using `jest-cli`, just add `babel-jest` and it will
|
9 | automatically compile JavaScript code using babel.
|
10 |
|
11 | ```bash
|
12 | yarn add --dev babel-jest babel-core
|
13 | ```
|
14 |
|
15 | > Note: If you are using babel version 7 you have to install `babel-jest` with
|
16 | >
|
17 | > ```bash
|
18 | > yarn add --dev babel-jest babel-core@^7.0.0-0 @babel/core
|
19 | > ```
|
20 |
|
21 | If you would like to write your own preprocessor, uninstall and delete
|
22 | babel-jest and set the
|
23 | [config.transform](http://facebook.github.io/jest/docs/configuration.html#transform-object-string-string)
|
24 | option to your preprocessor.
|
25 |
|
26 | ## Setup
|
27 |
|
28 | _Note: this step is only required if you are using `babel-jest` with additional
|
29 | code preprocessors._
|
30 |
|
31 | To explicitly define `babel-jest` as a transformer for your JavaScript code, map
|
32 | _.js_ files to the `babel-jest` module.
|
33 |
|
34 | ```json
|
35 | "transform": {
|
36 | "^.+\\.jsx?$": "babel-jest"
|
37 | },
|
38 | ```
|