Skip to content Skip to sidebar Skip to footer

Jest Error Unexpected Token ... (es6)

I am getting the following error whenever I run jest in commandline: ● Test suite failed to run /Users///src/login/LoginAPI.js:13 ...headers,

Solution 1:

You need to use a specific babel preset for this syntax. Check this preset

npm install --save-dev babel-plugin-transform-object-rest-spread

And then add this to your .babelrc

{"plugins":["transform-object-rest-spread"]}

You might want to add stage-2 as it has more ES6 goodies.

Note:Jest can read your .babelrc file

Solution 2:

In babel 7, babel-plugin-transform-object-rest-spread will report error: SpreadProperty has been renamed to SpreadElement.

So I use:

npm install --save-dev@babel/plugin-proposal-object-rest-spread

and config .babelrc

{
  "plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

Solution 3:

There are several solutions to this I believe, this GitHub Issue should outline some of them. I would give this a try first:

{"presets":["es2015","stage-3","react"]}

Solution 4:

Add "schema-utils": "2.6.6" as "dependencies" in your package.json

"schema-utils":"2.6.6",

Post a Comment for "Jest Error Unexpected Token ... (es6)"