How to use the utils function from istanbul

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

109
110
111
112
113
114
115
116
117
118

  if (!global[opts.coverageVariable]) throw new Error('no coverage data found, run tests before calling `summarizeCoverage`');

  var collector = new Collector();
  collector.add(global[opts.coverageVariable]);
  return istanbul.utils.summarizeCoverage(collector.getFinalCoverage());
};

plugin.writeReports = function (opts) {
  if (typeof opts === 'string') opts = { dir: opts };
fork icon87
star icon186
watch icon6

+ 9 other calls in file

48
49
50
51
52
53
54
55
56
57
};

var coverageThresholdCheck = function coverageThresholdCheck(collector) {

  // http://gotwarlost.github.io/istanbul/public/apidocs/classes/ObjectUtils.html
  var objUtils = istanbul.utils;

  // Check against thresholds
  collector.files().forEach(function eachFiles(file) {
    var summary = objUtils.summarizeFileCoverage(
fork icon23
star icon28
watch icon9

+ 3 other calls in file

42
43
44
45
46
47
48
49
50
51
  }
});
Object.defineProperty(exports, 'utils', {
  enumerable: true,
  get: function get() {
    return _istanbul.utils;
  }
});
Object.defineProperty(exports, 'matcherFor', {
  enumerable: true,
fork icon1
star icon0
watch icon0

137
138
139
140
141
142
143
144
145
146
}

var thresholds = helper.merge({}, defaultThresholds, config.check)

var rawCoverage = collector.getFinalCoverage()
var globalResults = istanbul.utils.summarizeCoverage(removeFiles(rawCoverage, thresholds.global.excludes))
var eachResults = removeFiles(rawCoverage, thresholds.each.excludes)

// Summarize per-file results and mutate original results.
Object.keys(eachResults).forEach(function (key) {
fork icon0
star icon0
watch icon1

54
55
56
57
58
59
60
61
62
63
    });
},

getTreeSummary: function(collector, filePath, fileOnly) {
    var summarizer = new istanbul.TreeSummarizer();
    var utils = istanbul.utils;
    collector.files().forEach(function (key) {
        if(filePath == null || key.startWith(filePath)) {
            if(fileOnly) {
                if(key == filePath)
fork icon0
star icon0
watch icon1

+ 3 other calls in file