How to use the Collector function from istanbul

Find comprehensive JavaScript istanbul.Collector code examples handpicked from public code repositorys.

6
7
8
9
10
11
12
13
14
15
// defined in this package.json instead of the one defined in istanbul-threshold-checker.
var istanbul = require('istanbul');
var _ = require('lodash');
var applySourceMap = require('vinyl-sourcemaps-apply');
var Report = istanbul.Report;
var Collector = istanbul.Collector;
var PluginError = require('plugin-error');

var PLUGIN_NAME = 'gulp-istanbul';
var COVERAGE_VARIABLE = '$$cov_' + new Date().getTime() + '$$';
fork icon87
star icon186
watch icon6

+ 9 other calls in file

36
37
38
39
40
41
42
43
44
45
  await fs.writeFile(intermediatePath, JSON.stringify(coverage, null, 2));
  debug(`stored intermediate coverage for ${packageName}`);
}

async function combine(packageName) {
  const collector = new Collector();
  const pattern = `reports/coverage/intermediate/${packageName}{.json,/**/*.json}`;
  const files = await g(pattern);

  for (const f of files) {
fork icon304
star icon151
watch icon43

+ 11 other calls in file

158
159
160
161
162
163
164
165
166
167
    return ret;
}

core.render = function (filePath, res, prefix) {
    prefix = '/coverage';
    var collector = new istanbul.Collector(),
        treeSummary,
        pathMap,
        linkMapper,
        outputNode,
fork icon41
star icon0
watch icon14

92
93
94
95
96
97
98
99
100
  collectors = Object.create(null);

  // TODO(vojta): remove once we don't care about Karma 0.10
  if (browsers) {
    browsers.forEach(function(browser) {
      collectors[browser.id] = new istanbul.Collector();
    });
  }
};
fork icon24
star icon136
watch icon13

+ 3 other calls in file

104
105
106
107
108
109
110
111
112
113
};

var collectReports = function collectReports(opts) {
  var reportFile = path.resolve(reportingDir, options.coverage.reportFile),
    // http://gotwarlost.github.io/istanbul/public/apidocs/classes/Collector.html
    collector = new istanbul.Collector(),
    cov = global[coverageVar];

  if (options.coverage.includeAllSources) {
    includeAllSources(cov, opts);
fork icon23
star icon28
watch icon9

+ 3 other calls in file

11
12
13
14
15
16
17
18
19
20
if (options.reportDir) reporterOpts.dir = options.reportDir;
if (process.env.ISTANBUL_REPORT_DIR) reporterOpts.dir = process.env.ISTANBUL_REPORT_DIR;

runner.on('end', function(){
    var cov = global.__coverage__ || {},
        collector = new istanbul.Collector();

    collector.add(cov);

    reporters.forEach(function(reporter) {
fork icon15
star icon199
watch icon11

35
36
37
38
39
40
41
42
43
44
45
46
47
);
const coverage = loadCoverage(wctCoverage);


const collector = remap(coverage);


const newCollector = new Collector();


/**
 * Manually filter some stuff out!
 */
fork icon5
star icon22
watch icon0

12
13
14
15
16
17
18
19
20
21
  }
});
Object.defineProperty(exports, 'Collector', {
  enumerable: true,
  get: function get() {
    return _istanbul.Collector;
  }
});
Object.defineProperty(exports, 'hook', {
  enumerable: true,
fork icon1
star icon0
watch icon0

209
210
211
212
213
214
215
216
217
218
    browsers.forEach(this.onBrowserStart.bind(this))
  }
}

this.onBrowserStart = function (browser) {
  collectors[browser.id] = new istanbul.Collector()

  if (!includeAllSources) return

  collectors[browser.id].add(coverageMap.get())
fork icon0
star icon0
watch icon1

9
10
11
12
13
14
15
16
17
18

let localInstrumenter = new istanbul.Instrumenter({
  coverageVariable: '__coverage__',
  instrumenter: istanbul.Instrumenter
})
let localCollector = new istanbul.Collector()
let localReporter = new istanbul.Reporter(null, `coverage/test-${testNumber}`)

// handle testableFiles
let testableFilesToInject = JSON.parse(process.env.TESTABLEFILES_JSON)
fork icon0
star icon0
watch icon2

16
17
18
19
20
21
22
23
24
25

module.exports = function (sourceDirs, opts, runner, _injected) {
    _injected = _injected || { };
    
    var Reporter = _injected.Reporter || istanbul.Reporter,
        Collector = _injected.Collector || istanbul.Collector;
    
    var matchFn = (function () {
        var REs = sourceDirs.map(function (sourceDir) {
            return {
fork icon0
star icon0
watch icon16

+ 7 other calls in file