2016-12-29 16:42:48 -05:00
|
|
|
var path = require('path');
|
2017-03-02 17:35:36 -05:00
|
|
|
var webpack = require('webpack');
|
2016-12-29 16:42:48 -05:00
|
|
|
var webpackConfig = require('./webpack.config.js');
|
|
|
|
var ROOT_PATH = path.resolve(__dirname, '..');
|
|
|
|
|
2017-03-02 17:35:36 -05:00
|
|
|
// remove problematic plugins
|
|
|
|
if (webpackConfig.plugins) {
|
2018-03-23 12:52:54 -04:00
|
|
|
webpackConfig.plugins = webpackConfig.plugins.filter(function(plugin) {
|
2017-03-02 17:35:36 -05:00
|
|
|
return !(
|
|
|
|
plugin instanceof webpack.optimize.CommonsChunkPlugin ||
|
2017-08-21 12:23:52 -04:00
|
|
|
plugin instanceof webpack.optimize.ModuleConcatenationPlugin ||
|
2017-03-02 17:35:36 -05:00
|
|
|
plugin instanceof webpack.DefinePlugin
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-31 05:34:41 -04:00
|
|
|
webpackConfig.devtool = 'cheap-inline-source-map';
|
|
|
|
|
2016-12-29 16:42:48 -05:00
|
|
|
// Karma configuration
|
|
|
|
module.exports = function(config) {
|
2018-01-21 01:16:25 -05:00
|
|
|
process.env.TZ = 'Etc/UTC';
|
|
|
|
|
2017-02-11 16:22:22 -05:00
|
|
|
var progressReporter = process.env.CI ? 'mocha' : 'progress';
|
2017-03-20 18:29:45 -04:00
|
|
|
|
|
|
|
var karmaConfig = {
|
2016-12-29 16:42:48 -05:00
|
|
|
basePath: ROOT_PATH,
|
2018-03-23 12:52:54 -04:00
|
|
|
browsers: ['ChromeHeadlessCustom'],
|
2017-06-13 13:37:36 -04:00
|
|
|
customLaunchers: {
|
2017-06-14 14:58:10 -04:00
|
|
|
ChromeHeadlessCustom: {
|
2017-06-13 13:37:36 -04:00
|
|
|
base: 'ChromeHeadless',
|
2017-06-14 14:58:10 -04:00
|
|
|
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',
|
|
|
|
],
|
2018-03-23 12:52:54 -04:00
|
|
|
},
|
2017-06-13 13:37:36 -04:00
|
|
|
},
|
2017-01-06 18:21:54 -05:00
|
|
|
frameworks: ['jasmine'],
|
2016-12-29 16:42:48 -05:00
|
|
|
files: [
|
2017-01-07 02:38:36 -05:00
|
|
|
{ pattern: 'spec/javascripts/test_bundle.js', watched: false },
|
2017-01-06 14:27:33 -05:00
|
|
|
{ pattern: 'spec/javascripts/fixtures/**/*@(.json|.html|.html.raw)', included: false },
|
2016-12-29 16:42:48 -05:00
|
|
|
],
|
|
|
|
preprocessors: {
|
2017-03-15 19:31:01 -04:00
|
|
|
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
|
2016-12-29 16:42:48 -05:00
|
|
|
},
|
2017-03-20 18:29:45 -04:00
|
|
|
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 = {
|
2017-02-10 13:29:03 -05:00
|
|
|
reports: ['html', 'text-summary'],
|
|
|
|
dir: 'coverage-javascript/',
|
|
|
|
subdir: '.',
|
2018-03-23 12:52:54 -04:00
|
|
|
fixWebpackSourcePaths: true,
|
2017-03-20 18:29:45 -04:00
|
|
|
};
|
2017-06-16 16:40:28 -04:00
|
|
|
karmaConfig.browserNoActivityTimeout = 60000; // 60 seconds
|
2017-03-20 18:29:45 -04:00
|
|
|
}
|
|
|
|
|
2017-06-14 14:58:10 -04:00
|
|
|
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-03-20 18:29:45 -04:00
|
|
|
config.set(karmaConfig);
|
2016-12-29 16:42:48 -05:00
|
|
|
};
|