Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80600 views
1
'use strict';
2
3
var DefaultTestReporter = require('./DefaultTestReporter');
4
var istanbul = require('istanbul');
5
var collector = new istanbul.Collector();
6
var reporter = new istanbul.Reporter();
7
8
function IstanbulTestReporter(customProcess) {
9
this.process = customProcess || process;
10
}
11
12
IstanbulTestReporter.prototype = new DefaultTestReporter();
13
14
IstanbulTestReporter.prototype.onTestResult =
15
function(config, testResult, aggregatedResults) {
16
DefaultTestReporter.prototype.onTestResult.call(
17
this, config, testResult, aggregatedResults
18
);
19
20
if (config.collectCoverage && testResult.coverage) {
21
collector.add(testResult.coverage);
22
}
23
};
24
25
IstanbulTestReporter.prototype.onRunComplete =
26
function (config, aggregatedResults) {
27
DefaultTestReporter.prototype.onRunComplete.call(
28
this, config, aggregatedResults
29
);
30
31
if (config.collectCoverage) {
32
reporter.addAll([ 'json', 'text', 'lcov', 'clover' ]);
33
reporter.write(collector, true, function () {
34
console.log('All reports generated');
35
});
36
}
37
};
38
39
module.exports = IstanbulTestReporter;
40
41