How to use the Instrumenter function from istanbul
Find comprehensive JavaScript istanbul.Instrumenter code examples handpicked from public code repositorys.
GitHub: beckermarc/cf-abacus
41 42 43 44 45 46 47 48 49
// Return a transform function that transforms a file and records the original // source and a source map in the given sets const transformer = (sources, maps, transformers) => { // Set up an instrument function that will instrument the relevant code const instrumenter = new istanbul.Instrumenter({ coverageVariable: '__coverage', preserveComments: true });
89
0
1
GitHub: SBoudrias/gulp-istanbul
20 21 22 23 24 25 26 27 28 29
var plugin = module.exports = function (opts) { opts = opts || {}; _.defaults(opts, { coverageVariable: COVERAGE_VARIABLE, instrumenter: istanbul.Instrumenter }); opts.includeUntested = opts.includeUntested === true; return through(function (file, enc, cb) {
87
186
6
+ 9 other calls in file
147 148 149 150 151 152 153 154 155 156
collectReports(opts); }; var istanbulMatcherRun = function istanbulMatcherRun(matchFn) { var instrumenter = new istanbul.Instrumenter({coverageVariable: coverageVar}); var transformer = instrumenter.instrumentSync.bind(instrumenter); var hookOpts = {verbose: options.isVerbose}; istanbul.hook.hookRequire(matchFn, transformer, hookOpts);
23
28
9
+ 3 other calls in file
22 23 24 25 26 27 28 29 30 31
return !!fileMap[path]; }, function (code, path) { return fileMap[path]; }); var instrumenter = new istanbul.Instrumenter(opts); return through(function (file, enc, cb) { if (!(file.contents instanceof Buffer)) { return cb(new PluginError(PLUGIN_NAME, 'streams not supported'), undefined);
87
0
2
65 66 67 68 69 70 71 72 73 74
var transformFctName = '_' + metricMapName + 'Transformer'; var transformedMetricMap = this[transformFctName](metricMap, metrics); this.coverState[metricMapName] = transformedMetricMap; }.bind(this)); return istanbul.Instrumenter.prototype.getPreamble.call(this, sourceCode, emitUseStrict); }; Instrumenter.prototype._statementMapTransformer = function(metrics) { return Object.keys(metrics)
102
0
3
+ 3 other calls in file
GitHub: gmetais/unusedjs
2 3 4 5 6 7 8 9 10
var fs = require('fs'); var path = require('path'); var istanbul = require('istanbul'); var HttpProxy = require('../lib/httpProxy'); var instrumenter = new istanbul.Instrumenter({ embedSource: true, noAutoWrap: true });
17
153
7
GitHub: marcelerz/preceptor
52 53 54 55 56 57 58 59 60 61
// Is coverage requested? if (((coverage === undefined) || (coverage === true)) && globalCoverageConfig.active) { // Prepare coverage instrumentation instrumenter = new istanbul.Instrumenter({ coverageVariable: coverageVar, preserveComments: true }); transformer = instrumenter.instrumentSync.bind(instrumenter); // Hook-up transformer for every new file loaded istanbul.hook.hookRequire(function (filePath) {
7
0
2
+ 5 other calls in file
GitHub: atmin/freak
63 64 65 66 67 68 69 70 71
var FILENAME = 'freak.js'; var fs = require('fs'); var file = fs.readFileSync(FILENAME).toString(); var istanbul = require('istanbul'); var instrumenter = new istanbul.Instrumenter(); var instrumented = instrumenter.instrumentSync(file, FILENAME); var freak = requireFromString(instrumented); -->
0
25
6
17 18 19 20 21 22 23 24 25
function Instrumenter(options) { if (!options) { options = {}; } istanbul.Instrumenter.call(this, options); // Call super constructor return this; }
102
0
2
+ 3 other calls in file
12 13 14 15 16 17 18 19 20
var temp = require('temp'); var mkdirp = require('mkdirp'); var istanbul = require('istanbul'); var Instrumenter = istanbul.Instrumenter; var Collector = istanbul.Collector; var Report = istanbul.Report; var Store = istanbul.Store;
3
2
2
GitHub: pushrocks/tapbuffer
5 6 7 8 9 10 11 12 13 14
let testNumber = parseInt(process.env.TESTNUMBER, 10) let istanbul = require('istanbul') let localInstrumenter = new istanbul.Instrumenter({ coverageVariable: '__coverage__', instrumenter: istanbul.Instrumenter }) let localCollector = new istanbul.Collector()
0
0
2
+ 3 other calls in file
GitHub: ZokugunJS/istanbul.cover
85 86 87 88 89 90 91 92 93
if(error) { return console.error(error); } var coverageVar = '$$cov_' + new Date().getTime() + '$$'; var instrumenter = new istanbul.Instrumenter({ coverageVariable: coverageVar, preserveComments: true });
0
0
2
+ 7 other calls in file
40 41 42 43 44 45 46 47 48 49
options = options || {}; options.coverageVariable = '__coverageId'; if (this.instrumenter) { return; } this.instrumenter = new istanbul.Instrumenter(options); var transformer = this.instrumenter.instrumentSync.bind(this.instrumenter); var me = this; var hook = istanbul.hook; hook.hookRequire(matchFunc, transformer, {
0
0
1
istanbul.Collector is the most popular function in istanbul (108 examples)