Skip to content

Commit 9699877

Browse files
author
Aleksey Karpenko
authored
Adding babel config inside "using-with-jest.md" (#1667)
* docs(using-with-jest.md): improving on using-with-jest docs file Adding more detailed "using with babel" paragraph since it was not fully complete and required additional steps that were not present in documentation. #1666 * docs(using-with-jest.md): fixing some punctuation typos #1666 * docs(using-with-jest.md): final edit and typos fix #1666
1 parent ba84544 commit 9699877

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

docs/installation/using-with-jest.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,36 @@ Then, you need to tell Jest to transform `.vue` files using `vue-jest`. You can
3131
}
3232
```
3333

34-
> **Note:** If you are using Babel 7 or higher, you will need to add [babel-bridge](https://github.com/babel/babel-bridge) to your devDependencies (`$ npm install --save-dev babel-core@^7.0.0-bridge.0`).
34+
### Using with Babel
35+
36+
If you are going to use `babel` and import vue single file components with `.vue` extension inside your tests, you will need to install babel and transform `.js` files with `babel-jest` .
37+
38+
```bash
39+
npm install --save-dev babel-jest @babel/core @babel/preset-env babel-core@^7.0.0-bridge.0
40+
```
41+
42+
Then, you need to tell Jest to transform `.js` files using `babel-jest`. You can do so by adding the following configuration in `package.json` or in a standalone [Jest config file](https://jestjs.io/docs/en/configuration):
43+
44+
```json
45+
{
46+
"jest": {
47+
"transform": {
48+
// process `*.js` files with `babel-jest`
49+
".*\\.(js)$": "babel-jest"
50+
}
51+
}
52+
}
53+
```
54+
55+
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`:
56+
57+
```json
58+
{
59+
"babel": {
60+
"presets": ["@babel/preset-env"]
61+
}
62+
}
63+
```
3564

3665
### Handling webpack Aliases
3766

0 commit comments

Comments
 (0)