Skip to content

docs(jest): Clarify babel config snippet #1764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/installation/using-with-jest.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ Then, you need to tell Jest to transform `.js` files using `babel-jest`. You can
}
```

Then you need to create babel config using [babel.config.json](https://babeljs.io/docs/en/configuration#babelconfigjson), [.babelrc.json](https://babeljs.io/docs/en/configuration#babelrcjson) or `package.json`:
Then you need to create babel config using [babel.config.json](https://babeljs.io/docs/en/configuration#babelconfigjson) or [.babelrc.json](https://babeljs.io/docs/en/configuration#babelrcjson) config files:

```json
{
"presets": ["@babel/preset-env"]
}
```

You can also add these options to `package.json`:

```json
{
Expand All @@ -62,7 +70,7 @@ Then you need to create babel config using [babel.config.json](https://babeljs.i
}
```

### Handling webpack Aliases
### Handling webpack aliases

If you use a resolve alias in the webpack config, e.g. aliasing `@` to `/src`, you need to add a matching config for Jest as well, using the `moduleNameMapper` option:

Expand Down