When using Babel 6 and Mocha, the stack trace reports a wrong line number. I am pretty sure this is because the transpiling adds extra code. This is new behavior in Babel 6 vs. Babel 5.x for me. Does anyone have a solution on how to fix this when using Mocha for unit tests?
Here is my .babelrc config:
{
"ignore": [
"node_modules",
"bower_components"
],
"presets": [
"es2015",
"react"
],
"plugins": [
"transform-react-constant-elements",
"syntax-async-functions",
"transform-regenerator"
]
}
Note: this is happening whether or not I require('babel-polyfill') at the entry point of my app.
A sample stack trace looks like this:
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)
Sourcemaps and
retainLines:true
option. Here's an example Gulp task:You also have to have
at the top of your compiled code (just the entry point, i.e. the "main" file as specified in your package.json)