karma-runner / karma-runner/karma-coverage

istanbul ignore annotation does not work in coverage

Open
#247 6 comments 16 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

Hello,
I have next dependencies installed for project: [dependencies.txt](https://github.com/karma-runner/karma-coverage/files/422809/dependencies.txt)
And here is my karma.conf.js: [karma.conf.txt](https://github.com/karma-runner/karma-coverage/files/422815/karma.conf.txt)
I have next block of code:

``` javascript
/* istanbul ignore next */
function appMenu(MenuService) {
/* istanbul ignore next */
return MenuService.loadAppMenu();
}
```

And here is the Coverage summary:

> Statements : 87% ( 87/100 )
> Branches : 62.5% ( 5/8 )
> Functions : 44.44% ( 4/9 )
> Lines : 87% ( 87/100 )

And here is a screenshot from html report:
![no_function_no_statement_coverage](https://cloud.githubusercontent.com/assets/4066101/17740646/12183886-64a2-11e6-8ac2-5421bf0a239c.PNG)

At the bottom of html report I see: Code coverage generated by istanbul

I tried different ways to ignore these two lines from coverage report:
![no_covered](https://cloud.githubusercontent.com/assets/4066101/17740714/45d22da8-64a2-11e6-9487-ddbe5cc43da2.PNG)

Could anyone help me to find a solution how to use ignore line/statement/branch from coverage report?
Thank you.

Contributor guide

Open the contributing guide

Research direction

Reproduce the report using the linked dependencies.txt and karma.conf.js, then inspect how the JavaScript coverage report handles the shown `istanbul ignore next` annotations. Compare the coverage summary and HTML report with the annotated function and statement; done means the intended ignored code no longer affects the reported coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.