"istanbul ignore next" over methods of an es6 class
Following example says, that doSomething is not covered, but i guess it should be "ignored"
class Foo {
/* istanbul ignore next */
doSomething () {
return 'something';
}
}
if i move the ignore-comment into the method, the return is ignored, but the function is still uncovered
+1 to this. Having issues ignoring an inquirer based function and callback which I plan to test at a later date after a refactor.
Found a workaround (spaces before and after the comment seem to be necessary):
class Foo {
bar /* istanbul ignore next */ () {
return 'biu~';
}
}
+1
If you're using babel and mocha, you can use the loose mode for ES6 classes:
{
"presets": ["es2015"],
"plugins": [
["transform-es2015-classes", {
"loose": true
}]
]
}
This will generate code like this:
/* istanbul ignore next */
MyClass.prototype.myMethod = function () { }
Which istanbul understands perfectly
EDIT: Otherwise babel would do sth like this:
_createClass(MyClass, [{
key: "myMethod",
/* istanbul ignore next */
value: function myMethod() {}
}]);
+1 for this
half way through 2016 now.. any update on this?
+1
This is still an issue, having to put the comment between descriptor and signature is a horrible looking hack I have to say.
+1
+1. Beginning of 2017, I am still waiting.
ye, I have agree with this. I didn't use coverage before, but now that i am using react-boilerplate, I do find it valuable.
I also understand (from a Martin Fowler article) that we shouldn't be neurotic over getting 100% coverage.
However I find it cumbersome to have to go through the whole list of files and percentages, to see wether a lack of coverage comes from files where I expect it to come from, or wether it is a new place where I actually should improve the testing. That's why I want to have it at 100% all the time, so I can see at once if something is wrong or not. Now I find myself fighting istanbul to get coverage to 100% for places that are hard or unnecessary to test, which is a bit frustrating.
/* istanbul ignore function */ /* istanbul ignore file */ /* istanbul ignore start */ /* istanbul ignore end */
would be great to have!
+1 for /* istanbul ignore file */
class Foo {
bar /* istanbul ignore next */ () {
return 'biu~';
}
}
This work-around doesn't work for this type of code:
.then(data => {
},
error /* istanbul ignore next */ => {
// no matter what, cannot switch coverage off here
});
For es6 react app I just did this:
const foo = /* istanbul ignore next */ () => {
return bar;
}
Who's still waiting for this in 2018?
The following works for my React class using the version of Istanbul that comes with Jest 22.4
/* istanbul ignore next */
componentWillReceiveProps(props) {
// ...
}
waiting for
/* istanbul ignore function */
/* istanbul ignore file */
/* istanbul ignore start */
/* istanbul ignore end */
greetings from Istanbul,.. May 2018
/* istanbul ignore file */ working well for me.
Currently using nyc v11.9.0
2019 +1
+1 to
/* istanbul ignore function */
It would be amazing. Or just an /* istanbul ignore next */ that works. The workaround does not work for Vue SPC.
As a lot of time has already passed, what about /* constantinople ignore next */?
As a lot of time has already passed, what about /* constantinople ignore next */?
Why they'd change it, I can't say.
Hi! I've hit a similar issue... we are using Relay containers (ex. createPaginationContainer) and I am testing only the Component which this HOC wraps. Therefore I would like to ignore the HOC in the coverage.
Here is an example what doesn't work and what works:
This doesn't work:
/* istanbul ignore next */ export default createPaginationContainer( myComponent, { query: graphql '...' }, getVariables: () => (), ...
This works:
export default createPaginationContainer( myComponent, { query: /* istanbul ignore next */ graphql '...' }, getVariables: /* istanbul ignore next */ () => (), ...
The working example is not so nice to see and write... so my question is: Is there anyway to do it like in the first example? Or has the Istanbul team some plans to support such ignores?
Thank you
Is this issue even being monitored? @gotwarlost +1
/* istanbul ignore start */ /* istanbul ignore end */
These two are really all that would be left from the op. They would alleviate the need for convenience the other two file and function commands though. They would be fantastic to have and likely would have garnered more usefulness overall, imho.
/* istanbul ignore file */ /* istanbul ignore function */
These two already exist and work from my testing with my typescript, istanbul, mocha, chia, sinon instance.
/* istanbul ignore start / / istanbul ignore end */
These two are really all that would be left from the op. They would alleviate the need for convenience the other two file and function commands though. They would be fantastic to have and likely would have garnered more usefulness overall, imho.
/* istanbul ignore file / / istanbul ignore function */
These two already exist and work from my testing with my typescript, istanbul, mocha, chia, sinon instance.
@brycepelletier /* istanbul ignore function */ didn't work for me. what's your version ?
...... 2020
...... 2020
I don't think this repo is updated anymore. The last commit was in 2017.
It just became a tradition to come here once a year to check
"karma-coverage-istanbul-reporter": "~2.0.1"
/* istanbul ignore next */
private myFunction() {...}
works for me in an angular-cli 8 project...
EDIT: oh, sry! i just realized that karma-istanbul refers to istanbuljs :D
+1 in 2020.