How to test ES6 modules with Jest.
Example:
sum.js
const sum = function (a, b
The solutions above didn't work for me. I was able to solve with this:
yarn add --dev babel-jest @babel/core @babel/preset-env @babel/preset-typescript
babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript'
],
};
where I'm using typescript.
Reference.