Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Generate an Istanbul report

  • Loading branch information...
commit 2b0487ca3a50f7e48f8752876d8c09723ff54252 1 parent 6d84f8e
@davglass authored
Showing with 30 additions and 1 deletion.
  1. +17 −0 lib/coverage.js
  2. +13 −1 lib/options.js
View
17 lib/coverage.js
@@ -263,7 +263,24 @@ exports.status = function(json) {
return out;
};
+var generateIstanbulHTML = function(options) {
+ var report = istanbul.Report.create('html', {
+ dir: options.istanbulReport
+ }),
+ collector = new istanbul.Collector();
+
+ coverageInfo.forEach(function (item) {
+ collector.add(item);
+ });
+ report.writeReport(collector, true);
+
+ process.exit(0);
+};
+
var getIstanbulCoverageReport = function (options) {
+ if (options.istanbulReport) {
+ return generateIstanbulHTML(options);
+ }
var lcovFile = options.coverageFileName,
prefix = options.sourceFilePrefix,
report = istanbul.Report.create('lcovonly', {
View
14 lib/options.js
@@ -15,6 +15,7 @@ var path = require('path'),
run: true,
quiet: false,
exitOnFail: false,
+ istanbulReport: false,
sourceFilePrefix: false,
coverageFileName: false
}, newPath, paths, a, p, t, v, concurrent, coverageFileName, sourceFilePrefix,
@@ -62,6 +63,14 @@ var path = require('path'),
throw("-sp requires an argument");
}
break;
+ case "--istanbul-report":
+ p = args.shift();
+ if (p) {
+ options.istanbulReport = p;
+ } else {
+ throw("Istanbul report needs a path");
+ }
+ break;
case "--no-run":
options.run = false;
break;
@@ -153,11 +162,14 @@ var path = require('path'),
console.log(' --junit JUnit XML export');
console.log(' --server Starts a static file server in the CWD, tests should be relative to this directory');
console.log(' --port <Number> The port to start the server on');
+ console.log(' --no-run Do not execute the tests, just prep the server (for other testing)');
+ console.log('');
+ console.log('Coverage Options');
console.log(' --coverage Generate a coverage report and print it to the screen (you must instrument your own files first)');
console.log(' --coverage-warn <Number> The percentage to highlight as low coverage: default is 80');
+ console.log(' --istanbul-report <Path> Generate an Instabul coverage report into this directory');
console.log(' -co --coverageFileName <path to export coverage file> The coverage data in lcov format.');
console.log(' -sp --sourceFilePrefix <path to sourcefile> The relative path to the original source file for use in the coverage results.');
- console.log(' --no-run Do not execute the tests, just prep the server (for other testing)');
process.exit();
break;
case "-v":
Please sign in to comment.
Something went wrong with that request. Please try again.