jest encountered unexpected token

我是研究僧i 提交于 2019-12-11 08:04:32

问题


I am facing this issue. after running my unit test. This same error occurs wherever the static variable present. do you have any solution for this? or what causing this issue

similarly, the same error showing for the auto binding too.

ex:

handle = ()=>{
}


回答1:


finally, I found the solution.

add this below lines in the babelrc file

"presets": ["env", "react"],
"plugins": ["transform-class-properties"]

And also if someone facing below issue, Kindly check your node version. it should be 8+ version. Because I faced this issue.

...this.state is undefined
^^^


来源:https://stackoverflow.com/questions/51076668/jest-encountered-unexpected-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!