UNPKG

968 BMarkdownView Raw
1# babel-jest
2
3[Babel](https://github.com/babel/babel) [jest](https://github.com/facebook/jest)
4plugin
5
6## Usage
7
8If you are already using `jest-cli`, just add `babel-jest` and it will
9automatically compile JavaScript code using babel.
10
11```bash
12yarn 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
21If you would like to write your own preprocessor, uninstall and delete
22babel-jest and set the
23[config.transform](http://facebook.github.io/jest/docs/configuration.html#transform-object-string-string)
24option to your preprocessor.
25
26## Setup
27
28_Note: this step is only required if you are using `babel-jest` with additional
29code preprocessors._
30
31To 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```