summaryrefslogtreecommitdiff
path: root/config/karma.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/karma.config.js')
-rw-r--r--config/karma.config.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/config/karma.config.js b/config/karma.config.js
index 84810332dc2..e1d7c30b1c2 100644
--- a/config/karma.config.js
+++ b/config/karma.config.js
@@ -22,6 +22,13 @@ webpackConfig.optimization.splitChunks = false;
// use quicker sourcemap option
webpackConfig.devtool = 'cheap-inline-source-map';
+// set BABEL_ENV to indicate when we're running code coverage
+webpackConfig.plugins.push(
+ new webpack.DefinePlugin({
+ 'process.env.BABEL_ENV': JSON.stringify(process.env.BABEL_ENV || process.env.NODE_ENV || null),
+ })
+);
+
const specFilters = argumentsParser
.option(
'-f, --filter-spec [filter]',
@@ -80,11 +87,12 @@ if (specFilters.length) {
module.exports = function(config) {
process.env.TZ = 'Etc/UTC';
- const progressReporter = process.env.CI ? 'mocha' : 'progress';
-
const karmaConfig = {
basePath: ROOT_PATH,
browsers: ['ChromeHeadlessCustom'],
+ client: {
+ color: !process.env.CI,
+ },
customLaunchers: {
ChromeHeadlessCustom: {
base: 'ChromeHeadless',
@@ -104,11 +112,19 @@ module.exports = function(config) {
preprocessors: {
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
},
- reporters: [progressReporter],
+ reporters: ['progress'],
webpack: webpackConfig,
webpackMiddleware: { stats: 'errors-only' },
};
+ if (process.env.CI) {
+ karmaConfig.reporters = ['mocha', 'junit'];
+ karmaConfig.junitReporter = {
+ outputFile: 'junit_karma.xml',
+ useBrowserName: false,
+ };
+ }
+
if (process.env.BABEL_ENV === 'coverage' || process.env.NODE_ENV === 'coverage') {
karmaConfig.reporters.push('coverage-istanbul');
karmaConfig.coverageIstanbulReporter = {