Skip to content

Commit

Permalink
Try using the same instrumentation as NYC from the Node tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottFreeCode committed Aug 2, 2017
1 parent fea20c5 commit afd632a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ var mkdirp = require('mkdirp');
var baseBundleDirpath = path.join(__dirname, '.karma');
var osName = require('os-name');
var workaroundMultiplePreprocessorIncompatibility = require('browserify-istanbul');
var karmaCoverageIstanbul;
var istanbulLib;
try {
karmaCoverageIstanbul = require('karma-coverage/node_modules/istanbul');
} catch (ignore) {}
istanbulLib = require('nyc/node_modules/istanbul-lib-instrument');
} catch (ignore) {
istanbulLib = require('istanbul-lib-instrument');
}
var nyc = { Instrumenter: function (options) { return istanbulLib.createInstrumenter(options); } };

module.exports = function (config) {
var bundleDirpath;
Expand Down Expand Up @@ -153,12 +156,13 @@ module.exports = function (config) {
});
cfg.reporters.push('coverage');
cfg.coverageReporter = {
instrumenters: { istanbul: nyc },
reporters: [ { type: 'json' }, { type: 'text-summary' } ],
dir: 'coverage/reports/browser' + (ui ? '-' + ui : ''),
subdir: '.',
includeAllSources: true
};
cfg.browserify.transform = [ workaroundMultiplePreprocessorIncompatibility({ ignore: ['**/node_modules/**', '**/test/**'], instrumenter: karmaCoverageIstanbul }) ];
cfg.browserify.transform = [ workaroundMultiplePreprocessorIncompatibility({ ignore: ['**/node_modules/**', '**/test/**'], instrumenter: nyc, instrumenterConfig: { autoWrap: true, embedSource: true, produceSourceMap: true, noCompact: false } }) ];
console.error('Reporting coverage to ' + cfg.coverageReporter.dir);
}

Expand Down

0 comments on commit afd632a

Please sign in to comment.