Skip to content

Commit 020b464

Browse files
committed
Merge pull request #115 from hakubo/Accept-coverage.reporters
Default reporters lcov, json with a way to specify it from runner
2 parents e09abae + d16a2c2 commit 020b464

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/coverage.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var path = require('path'),
44
var istanbul,
55
collector,
66
options = {
7-
dir: 'coverage'
7+
dir: 'coverage',
8+
reporters: ['lcov', 'json']
89
};
910

1011
try {
@@ -38,7 +39,11 @@ exports.report = function() {
3839

3940
if (collector) {
4041
Report = istanbul.Report;
41-
reports = [Report.create('lcov', options), Report.create('json', options)];
42+
43+
reports = options.reporters.map(function (report) {
44+
return Report.create(report, options);
45+
});
46+
4247
reports.forEach(function(rep) {
4348
rep.writeReport(collector, true);
4449
});

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,10 @@ $ npm test
264264

265265
### Coverage
266266

267-
Code coverage via Istanbul. To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: {dir: "coverage/path"}` or pass `--cov` parameter in the shell. Coverage calculations based on code and tests passed to `node-qunit`.
267+
Code coverage via Istanbul.
268+
269+
To utilize, install `istanbul` and set option `coverage: true` or give a path where to store report `coverage: {dir: "coverage/path"}` or pass `--cov` parameter in the shell.
270+
271+
To specify the format of coverage report pass reporters array to the coverage options: `coverage: {reporters: ['lcov', 'json']}` (default)
272+
273+
Coverage calculations based on code and tests passed to `node-qunit`.

0 commit comments

Comments
 (0)