2017-08-17 22:00:37 +05:30
|
|
|
var path = require('path');
|
|
|
|
var webpack = require('webpack');
|
|
|
|
var webpackConfig = require('./webpack.config.js');
|
|
|
|
var ROOT_PATH = path.resolve(__dirname, '..');
|
|
|
|
|
|
|
|
// remove problematic plugins
|
|
|
|
if (webpackConfig.plugins) {
|
|
|
|
webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) {
|
|
|
|
return !(
|
|
|
|
plugin instanceof webpack.optimize.CommonsChunkPlugin ||
|
2018-03-17 18:26:18 +05:30
|
|
|
plugin instanceof webpack.optimize.ModuleConcatenationPlugin ||
|
2017-08-17 22:00:37 +05:30
|
|
|
plugin instanceof webpack.DefinePlugin
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
webpackConfig.devtool = 'cheap-inline-source-map';
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
// Karma configuration
|
|
|
|
module.exports = function(config) {
|
2018-03-17 18:26:18 +05:30
|
|
|
process.env.TZ = 'Etc/UTC';
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
var progressReporter = process.env.CI ? 'mocha' : 'progress';
|
|
|
|
|
|
|
|
var karmaConfig = {
|
|
|
|
basePath: ROOT_PATH,
|
2018-03-27 19:54:05 +05:30
|
|
|
browsers: ['ChromeHeadlessCustom'],
|
2017-09-10 17:25:29 +05:30
|
|
|
customLaunchers: {
|
|
|
|
ChromeHeadlessCustom: {
|
|
|
|
base: 'ChromeHeadless',
|
|
|
|
displayName: 'Chrome',
|
|
|
|
flags: [
|
|
|
|
// chrome cannot run in sandboxed mode inside a docker container unless it is run with
|
|
|
|
// escalated kernel privileges (e.g. docker run --cap-add=CAP_SYS_ADMIN)
|
|
|
|
'--no-sandbox',
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
frameworks: ['jasmine'],
|
|
|
|
files: [
|
|
|
|
{ pattern: 'spec/javascripts/test_bundle.js', watched: false },
|
|
|
|
{ pattern: 'spec/javascripts/fixtures/**/*@(.json|.html|.html.raw)', included: false },
|
|
|
|
],
|
|
|
|
preprocessors: {
|
|
|
|
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
|
|
|
|
},
|
|
|
|
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
|
|
|
|
};
|
2017-09-10 17:25:29 +05:30
|
|
|
karmaConfig.browserNoActivityTimeout = 60000; // 60 seconds
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.DEBUG) {
|
|
|
|
karmaConfig.logLevel = config.LOG_DEBUG;
|
|
|
|
process.env.CHROME_LOG_FILE = process.env.CHROME_LOG_FILE || 'chrome_debug.log';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.CHROME_LOG_FILE) {
|
|
|
|
karmaConfig.customLaunchers.ChromeHeadlessCustom.flags.push('--enable-logging', '--v=1');
|
|
|
|
}
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
config.set(karmaConfig);
|
|
|
|
};
|