BigW Consortium Gitlab

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

6 7 8 9 10 11 12 13 14 15
// remove problematic plugins
if (webpackConfig.plugins) {
  webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) {
    return !(
      plugin instanceof webpack.optimize.CommonsChunkPlugin ||
      plugin instanceof webpack.DefinePlugin
    );
  });
}

16 17
// Karma configuration
module.exports = function(config) {
18
  var progressReporter = process.env.CI ? 'mocha' : 'progress';
19 20

  var karmaConfig = {
21
    basePath: ROOT_PATH,
22
    browsers: ['PhantomJS'],
23
    frameworks: ['jasmine'],
24
    files: [
25
      { pattern: 'spec/javascripts/test_bundle.js', watched: false },
26
      { pattern: 'spec/javascripts/fixtures/**/*@(.json|.html|.html.raw)', included: false },
27 28
    ],
    preprocessors: {
29
      'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
30
    },
31 32 33 34 35 36 37 38
    reporters: [progressReporter],
    webpack: webpackConfig,
    webpackMiddleware: { stats: 'errors-only' },
  };

  if (process.env.BABEL_ENV === 'coverage' || process.env.NODE_ENV === 'coverage') {
    karmaConfig.reporters.push('coverage-istanbul');
    karmaConfig.coverageIstanbulReporter = {
39 40 41 42
      reports: ['html', 'text-summary'],
      dir: 'coverage-javascript/',
      subdir: '.',
      fixWebpackSourcePaths: true
43 44 45 46
    };
  }

  config.set(karmaConfig);
47
};