1. install Babel and its Jest transformer
npm install --save-dev babel-jest @babel/core @babel/preset-env
2. Create a babel.config.js file in your project root (if it doesn’t exist) and configure it like this
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }], // Transpile based on the current Node.js version
],
};
3. npm test