How to setup jest for ES6 syntax

Photo by Max Chen on Unsplash

How to setup jest for ES6 syntax

Install the following packages:

"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"babel-jest": "^26.0.1",
"jest": "^26.0.1"

Create a file babel.config.json to be used by babel:

{
  "presets": ["@babel/preset-env"]
}

Now you should be able to write unit tests in ES6 syntax.