From 038ed9ad46ac52a7ab5f2d86f6e48b392f0fb4d9 Mon Sep 17 00:00:00 2001 From: winniehell Date: Wed, 15 Feb 2017 23:39:45 +0100 Subject: [PATCH] Move babel config for instanbul to karma config (!9286) --- changelogs/unreleased/instrument-in-karma.yml | 4 ++++ config/karma.config.js | 11 +++++++++++ config/webpack.config.js | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/instrument-in-karma.yml diff --git a/changelogs/unreleased/instrument-in-karma.yml b/changelogs/unreleased/instrument-in-karma.yml new file mode 100644 index 00000000000..cfabf2569fe --- /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 a1fbeab1f46..a16e2d2077f 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) { config.set({ diff --git a/config/webpack.config.js b/config/webpack.config.js index e63775e43ce..ac117522005 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -54,7 +54,6 @@ var config = { exclude: /(node_modules|vendor\/assets)/, loader: 'babel-loader', options: { - plugins: IS_PRODUCTION ? [] : ['istanbul'], presets: [ ["es2015", {"modules": false}], 'stage-2' -- GitLab