diff --git a/config/karma.config.js b/config/karma.config.js index 74dc5c13c70..cad3c0e9193 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -6,6 +6,7 @@ const argumentsParser = require('commander'); const webpackConfig = require('./webpack.config.js'); const ROOT_PATH = path.resolve(__dirname, '..'); +const GENERATE_COVERAGE_REPORT = process.env.BABEL_ENV === 'coverage' || process.env.NODE_ENV === 'coverage'; function fatalError(message) { console.error(chalk.red(`\nError: ${message}\n`)); @@ -22,6 +23,10 @@ webpackConfig.optimization.splitChunks = false; // use quicker sourcemap option webpackConfig.devtool = 'cheap-inline-source-map'; +webpackConfig.plugins.push( + new webpack.DefinePlugin({ GENERATE_COVERAGE_REPORT }), +); + const specFilters = argumentsParser .option( '-f, --filter-spec [filter]', @@ -118,7 +123,7 @@ module.exports = function(config) { }; } - if (process.env.BABEL_ENV === 'coverage' || process.env.NODE_ENV === 'coverage') { + if (GENERATE_COVERAGE_REPORT) { karmaConfig.reporters.push('coverage-istanbul'); karmaConfig.coverageIstanbulReporter = { reports: ['html', 'text-summary'], diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 96c0844f83c..ffabd661c09 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -155,8 +155,8 @@ describe('test errors', () => { // if we're generating coverage reports, make sure to include all files so // that we can catch files with 0% coverage // see: https://github.com/deepsweet/istanbul-instrumenter-loader/issues/15 -if (process.env.BABEL_ENV === 'coverage') { // exempt these files from the coverage report +if (GENERATE_COVERAGE_REPORT) { const troubleMakers = [ './blob_edit/blob_bundle.js', './boards/components/modal/empty_state.vue',