Skip to content
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

Add introduce about "useBabelrc" and ES import #270

Merged
merged 3 commits into from
Jul 17, 2017
Merged
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,43 @@ your Jest configuration:

By default Jest ignores everything in `node_modules`. This setting prevents Jest from ignoring the package you're interested in, in this case `@foo`, while continuing to ignore everything else in `node_modules`.

### Test code w/ ES (Webpack 2+) dynamic import
Newest Webpack introduced ES dynamic import which cannot be handled by babel without plugins even with env preset.
In development usually use `babel-plugin-syntax-dynamic-import` to prevent errors.
But in tests it have to be converted to commonjs' require:
```
npm install -D babel-plugin-syntax-dynamic-import babel-plugin-dynamic-import-node
```
```
// .babalrc
{
// ...
"plugins" : [
"syntax-dynamic-import"
],
"env" : {
"test": {
"plugins": [
"dynamic-import-node"
]
}
}
}
```

Notice, by default `ts-jest` will not use project .babelrc, so `"useBabelrc": true` must be set.
```json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need to repeat this code snippet again. We can reference the main one here IMO.

// package.json
{
"jest": {
"globals": {
"ts-jest": {
"useBabelrc": true
}
}
}
}
```

## Known Limitations
### Known limitations for TS compiler options
Expand Down