0

I'm using Jasmine as the testing framework for my AngularJS application. I run the tests with the help of Grunt & KarmaJS. KarmaJS also generates the code coverage with the help of karma-coverage.

Now I've created a model for configuaration data, which I also have to instantiate for other tests. Because of this instantiation I get a code coverage for this file although I haven't done any tests for it. Only because while the test run all of the lines were used, the coverage is 100%.

Now the question: Is there a way to specify in my tests which files they cover?

In PHP Unit there is an @covers annotation which specifies what code is covered with the test.

Thx

Lord Midi
  • 754
  • 1
  • 9
  • 25

1 Answers1

1

Since karma-coverage uses Istanbul under the hood, all configuration for Istanbul should work for karma-coverage.

In Istanbul, you can specify that a block of code be ignored for coverage purposes. You can try placing something like this at the top of your file:

/* istanbul ignore next */

I haven't tried this myself, but I'd bet that this or something similar would do what you want it to do.

Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
  • First of all thanks for the reponse and the link. But that is not what I want to do. This excludes code from being included in the coverage report. But I need to anotate my tests which code they cover. With the ignore comment I annotate inside of the source lines of code which should not be considered in the coverage report. But maybe someone found a nice workaround with the help of ignore but I can't see the solution here. – Lord Midi Dec 29 '15 at 15:48