karma-runner / karma-runner/karma-coverage

There is no way of retrieving the code coverage report programmaticaly

Open
#215 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

For the development of our JS Mutation testing framework [stryker](http://github.com/infosupport/stryker) we want to programmatically receive the code coverage report. We're using karma via the [public api](http://karma-runner.github.io/0.13/dev/public-api.html).

Right now: we have 2 issues:
1. We do not know when the coverage report has been written.
2. We need to collect the coverage report from disk.

I want to add a new feature: 2 birds with one stone.

I want to raise an event called `coverage_complete` whenever the reporter is done with a coverage report. In order to do that, i want to add the `emitter` as inject-able in `reporter.js`.

Next, i want to add a new reporter type: `inMemory` or something. When that reporter is active, it will provide the result of `collector.getFinalCoverage()` to the `coverage_complete` event. I don't want to add the report to every event throw, because of possible performance overhead. Only when the `inMemory` report type is in the list.

@dignifiedquire do you agree with this approach?

Contributor guide

Open the contributing guide

Research direction

Start in reporter.js and trace how coverage reporters receive the collector and finish writing reports; inspect collector.getFinalCoverage() and the existing event flow. The work is done when a coverage_complete event is raised after reporting and the inMemory reporter supplies the final coverage without affecting other reporter types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Feature
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.