diff --git a/changelogs/unreleased/instrument-in-karma.yml b/changelogs/unreleased/instrument-in-karma.yml new file mode 100644 index 0000000000000000000000000000000000000000..cfabf2569fe7e85bf128b0da9bfd05b914cd0e3c --- /dev/null +++ b/changelogs/unreleased/instrument-in-karma.yml @@ -0,0 +1,4 @@ +--- +title: Move babel config for instanbul to karma config +merge_request: 9286 +author: winniehell diff --git a/config/karma.config.js b/config/karma.config.js index 5b472780aed292ff23af63f4300109fef7ae072a..2f3cc9324131acde61cc0d28e1e3b8d0c2074102 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -2,6 +2,17 @@ var path = require('path'); var webpackConfig = require('./webpack.config.js'); var ROOT_PATH = path.resolve(__dirname, '..'); +// 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'); +} + // Karma configuration module.exports = function(config) { var progressReporter = process.env.CI ? 'mocha' : 'progress'; diff --git a/config/webpack.config.js b/config/webpack.config.js index 8d981c76c1afd4e2ecfd7826a48630f31ace3f26..01c1a5bfb99582fed747e8e3f689720e4d61310a 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -55,7 +55,6 @@ var config = { exclude: /(node_modules|vendor\/assets)/, loader: 'babel-loader', options: { - plugins: IS_PRODUCTION ? [] : ['istanbul'], presets: [ ["es2015", {"modules": false}], 'stage-2'