Getting Karma, 6to5ify and Istanbul to play ball

醉酒当歌 提交于 2019-12-05 05:08:40

So, apparently I need browserify-istanbul, and I need the browserify configure hook, like so:

var to5ify = require('6to5ify');
var hbsfy = require('hbsfy');
var cover = require('browserify-istanbul');

var coverOptions = {
  ignore: ['**/*Spec.js', '**/lib/*.js', '**/fixtures/*.hbs'],
  defaultIgnore: true
}

module.exports = function(karma){
  karma.set({
    frameworks: ["browserify", "mocha", "chai-sinon"],
    browserify: {
      debug: false,
      extensions: [".js", ".hbs"],
      configure: function(bundle){
        bundle.on('prebundle', function(){
          bundle
            .transform(to5ify)
            .transform(hbsfy)
            .transform(cover(coverOptions));
        });
      }
    },
    reporters: ["dots", "osx", "junit", "coverage"],
    coverageReporter: {
      type: "text"
    },
    junitReporter: {
      outputFile: "spec/reports/test-results.xml"
    },
    preprocessors: {
      "spec/**/*": ["browserify"]
    },
    browsers: ["PhantomJS"],
    files: ["spec/unit/**/*Spec.js"],
    logLevel: "LOG_DEBUG",
    autoWatch: true
  });
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!