1 | # babel-jest
|
2 |
|
3 | [Babel](https://github.com/babel/babel) [jest](https://github.com/facebook/jest) plugin
|
4 |
|
5 | ## Usage
|
6 |
|
7 | If you are already using `jest-cli`, just add `babel-jest` and it will automatically compile JavaScript code using babel.
|
8 |
|
9 | ```
|
10 | npm install --save-dev babel-jest
|
11 | ```
|
12 |
|
13 | If you would like to write your own preprocessor, uninstall and delete babel-jest and set the [config.transform](http://facebook.github.io/jest/docs/configuration.html#transform-object-string-string) option to your preprocessor.
|
14 |
|
15 | ## Setup
|
16 |
|
17 | *Note: this step is only required if you are using `babel-jest` with additional code preprocessors.*
|
18 |
|
19 | To explicitly define `babel-jest` as a transformer for your JavaScript code, map *.js* files to the `babel-jest` module.
|
20 |
|
21 | ```json
|
22 | "transform": {
|
23 | "^.+\\.jsx?$": "babel-jest"
|
24 | },
|
25 | ```
|