diff options
Diffstat (limited to 'config/karma.config.js')
-rw-r--r-- | config/karma.config.js | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/config/karma.config.js b/config/karma.config.js index c1d3751d88f..eb082dd28bf 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -3,17 +3,6 @@ var webpack = require('webpack'); var webpackConfig = require('./webpack.config.js'); var ROOT_PATH = path.resolve(__dirname, '..'); -// add coverage instrumentation to babel config -if (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'); -} - // remove problematic plugins if (webpackConfig.plugins) { webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) { @@ -27,7 +16,8 @@ if (webpackConfig.plugins) { // Karma configuration module.exports = function(config) { var progressReporter = process.env.CI ? 'mocha' : 'progress'; - config.set({ + + var karmaConfig = { basePath: ROOT_PATH, browsers: ['PhantomJS'], frameworks: ['jasmine'], @@ -38,14 +28,20 @@ module.exports = function(config) { preprocessors: { 'spec/javascripts/**/*.js': ['webpack', 'sourcemap'], }, - reporters: [progressReporter, 'coverage-istanbul'], - coverageIstanbulReporter: { + 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 = { reports: ['html', 'text-summary'], dir: 'coverage-javascript/', subdir: '.', fixWebpackSourcePaths: true - }, - webpack: webpackConfig, - webpackMiddleware: { stats: 'errors-only' }, - }); + }; + } + + config.set(karmaConfig); }; |