BigW Consortium Gitlab

karma.config.js 1.32 KB
Newer Older
1 2 3 4
var path = require('path');
var webpackConfig = require('./webpack.config.js');
var ROOT_PATH = path.resolve(__dirname, '..');

5 6 7 8 9 10 11 12 13 14 15
// add coverage instrumentation to babel config
if (webpackConfig && webpackConfig.module && webpackConfig.module.rules) {
  var babelConfig = webpackConfig.module.rules.find(function (rule) {
    return rule.loader === 'babel-loader';
  });

  babelConfig.options = babelConfig.options || {};
  babelConfig.options.plugins = babelConfig.options.plugins || [];
  babelConfig.options.plugins.push('istanbul');
}

16 17
// Karma configuration
module.exports = function(config) {
18
  var progressReporter = process.env.CI ? 'mocha' : 'progress';
19 20
  config.set({
    basePath: ROOT_PATH,
21
    browsers: ['PhantomJS'],
22
    frameworks: ['jasmine'],
23
    files: [
24
      { pattern: 'spec/javascripts/test_bundle.js', watched: false },
25
      { pattern: 'spec/javascripts/fixtures/**/*@(.json|.html|.html.raw)', included: false },
26 27
    ],
    preprocessors: {
28
      'spec/javascripts/**/*.js?(.es6)': ['webpack', 'sourcemap'],
29
    },
30
    reporters: [progressReporter, 'coverage-istanbul'],
31 32 33 34 35 36
    coverageIstanbulReporter: {
      reports: ['html', 'text-summary'],
      dir: 'coverage-javascript/',
      subdir: '.',
      fixWebpackSourcePaths: true
    },
37 38 39 40
    webpack: webpackConfig,
    webpackMiddleware: { stats: 'errors-only' },
  });
};