karma-runner / karma-runner/karma-coverage

Karma-coverage does not show test coverage but function call coverage

Open
#185 2 comments 1 reaction 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

When I run the example from http://ariya.ofilabs.com/2013/10/code-coverage-of-jasmine-tests-using-istanbul-and-karma.html The coverage is 100%. When I add the self() function into sqrt.js:

```
var My = {
sqrt: function(x) {
if (x < 0) throw new Error("sqrt can't work on negative number");
return Math.exp(Math.log(x)/2);
},

self: function(x) {
return x;
}
};

My.self();
```

the report shows 100% coverage although there is not test for the self function.

Contributor guide

Open the contributing guide

Research direction

Reproduce the example from the linked Istanbul and Karma coverage article, then add the shown self function to sqrt.js and inspect the generated report. Trace why the report remains at 100% despite the untested function. Done means the report correctly reflects that self is not covered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.