Closed jonathanong closed 9 years ago
I'll look into debugging this ASAP. There is definitely something weird with the way I am compiling and that is not ideal.
On another note, you are likely going to run into trouble down the road using iojs and this tool together. Tests should be run using babel-node or code compiled by babel. You'll be running code that is not compiled during your tests with iojs and istanbul is going to be referencing compiled code. I'm not sure what will break, but something almost definitely will.
i'm mostly using babel for the better esprima support because I use basically all the es6 features in io.js, but esprima nor esprima-harmony can really handle it. hacky, yes. hoping istanbul uses babel as their esprima or something.
isparta has the same issue. But I see you bumped the babel dep, so maybe I can switch over.
@jonathanong @Swatinem This is actually a weird combo of babel doing weird stuff and istanbul doing weird stuff. I'll try to break it down.
Istanbul seems to fail ignoring if the comment is not separated by spaces on the right from other code.
For an example:
//this fails
doSomething(/* istanbul ignore next */function () {
});
//this succeeds
doSomething(/* istanbul ignore next */ function () {
});
The only difference in failing and succeeding is the space before the function keyword. Unfortunately, babel strips all spaces between the comment and the function keyword when it compiles. While babel's behavior is not ideal, I think istanbul itself is at fault for the bug. I'll see if I can get some help with istanbul's behavior.
For the short term, you can fix problems like your example by putting ignore comments on their own line:
'use strict';
module.exports = function () {
return Promise.resolve(true).catch(
/* istanbul ignore next */
function (err) {
console.error('this should be ignored');
}
);
}
example: https://github.com/jonathanong/babel-istanbul-test
https://travis-ci.org/jonathanong/babel-istanbul-test
should have 100% coverage