开玩笑遇到意外令牌 [英] jest encountered unexpected token

查看:98
本文介绍了开玩笑遇到意外令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临这个问题.在运行我的单元测试之后.无论何时存在静态变量,都会发生相同的错误.您对此有什么解决方案吗?或导致此问题的原因

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.

例如:

handle = ()=>{
}

推荐答案

最后,我找到了解决方案.

finally, I found the solution.

将此内容添加到babelrc文件的以下行

add this below lines in the babelrc file

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

如果有人遇到以下问题,请检查您的节点版本.它应该是8+版本.因为我遇到了这个问题.

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
^^^

这篇关于开玩笑遇到意外令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆