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-02-15 17:39:45 -05:00
|
|
|
// add coverage instrumentation to babel config
|
2017-03-02 17:35:36 -05:00
|
|
|
if (webpackConfig.module && webpackConfig.module.rules) {
|
2017-02-15 17:39:45 -05:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2017-03-02 17:35:36 -05:00
|
|
|
// remove problematic plugins
|
|
|
|
if (webpackConfig.plugins) {
|
|
|
|
webpackConfig.plugins = webpackConfig.plugins.filter(function (plugin) {
|
|
|
|
return !(
|
|
|
|
plugin instanceof webpack.optimize.CommonsChunkPlugin ||
|
|
|
|
plugin instanceof webpack.DefinePlugin
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-12-29 16:42:48 -05:00
|
|
|
// Karma configuration
|
|
|
|
module.exports = function(config) {
|
2017-02-11 16:22:22 -05:00
|
|
|
var progressReporter = process.env.CI ? 'mocha' : 'progress';
|
2016-12-29 16:42:48 -05:00
|
|
|
config.set({
|
|
|
|
basePath: ROOT_PATH,
|
2017-01-13 11:05:26 -05:00
|
|
|
browsers: ['PhantomJS'],
|
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-02-11 16:22:22 -05:00
|
|
|
reporters: [progressReporter, 'coverage-istanbul'],
|
2017-02-10 13:29:03 -05:00
|
|
|
coverageIstanbulReporter: {
|
|
|
|
reports: ['html', 'text-summary'],
|
|
|
|
dir: 'coverage-javascript/',
|
|
|
|
subdir: '.',
|
|
|
|
fixWebpackSourcePaths: true
|
|
|
|
},
|
2016-12-29 16:42:48 -05:00
|
|
|
webpack: webpackConfig,
|
|
|
|
webpackMiddleware: { stats: 'errors-only' },
|
|
|
|
});
|
|
|
|
};
|