You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,12 +367,25 @@ This tells `ts-jest` (a preprocessor this preset using to transform TS files) to
367
367
368
368
#### Transpile js files through `babel-jest`
369
369
Some vendors publish their sources without transpiling. You need to say jest to transpile such files manually since `typescript` (and thus `ts-jest` used by this preset) do not transpile them.
370
-
1. Install `babel-preset-env` and add `.babelrc` (or modify existing if needed) with that contents:
371
-
```
372
-
{
373
-
"presets": ["env"]
374
-
}
370
+
371
+
1. Install `@babel/preset-env` and add `babel.config.js` (or modify existing if needed) with the following content:
372
+
```js
373
+
module.exports=function(api) {
374
+
api.cache(true);
375
+
376
+
constpresets= ['@babel/preset-env'];
377
+
constplugins= [];
378
+
379
+
return {
380
+
presets,
381
+
plugins,
382
+
};
383
+
};
384
+
375
385
```
386
+
387
+
*Note: do not use a `.babelrc` file otherwise the packages that you specify in the next step will not be picked up. CF [Babel documentation](https://babeljs.io/docs/en/configuration#what-s-your-use-case) and the comment `You want to compile node_modules? babel.config.js is for you!`*.
388
+
376
389
2. Update Jest configuration (by default TypeScript process untranspiled JS files which is source of the problem):
0 commit comments