当使用Babel 6和Mocha时,堆栈跟踪报告了错误的行号。我非常确定这是因为转译添加了额外的代码。对于我来说,这是Babel 6与Babel 5.x之间的新行为。当使用Mocha进行单元测试时,有人有解决此问题的解决方案吗?
这是我的.babelrc配置:
这是我的.babelrc配置:
{
"ignore": [
"node_modules",
"bower_components"
],
"presets": [
"es2015",
"react"
],
"plugins": [
"transform-react-constant-elements",
"syntax-async-functions",
"transform-regenerator"
]
}
注意:这种情况发生在我的应用程序入口点是否需要'require('babel-polyfill')的情况下。
示例堆栈跟踪如下:
TypeError: Cannot read property 'should' of undefined
at _callee2$ (test/unit/index.test.js:217:34)
at step (test/unit/index.test.js:27:284)