forked from bradleyboy/yarsk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-karma-config.js
65 lines (51 loc) · 1.35 KB
/
make-karma-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var webpackConfig = require('./webpack.config.js');
module.exports = function(options) {
var karmaConfig = {
frameworks: ['mocha', 'chai'],
browsers: ['PhantomJS'],
files: [
// This shim adds .bind to PhantomJS
'./phantomjs-shim.js',
'../app/**/__tests__/*.js',
],
preprocessors: {
'../app/**/__tests__/*.js': ['webpack'],
},
webpackMiddleware: {
noInfo: true,
},
reporters: ['mocha'],
plugins: [
'karma-webpack',
'karma-mocha',
'karma-chai',
'karma-phantomjs-launcher',
'karma-mocha-reporter',
],
};
if (options.coverage) {
// Needs to load first to prevent linting issues
webpackConfig.module.preLoaders = [
{
test: /\.jsx?$/,
exclude: /(__tests__|node_modules)/,
loader: 'isparta-instrumenter-loader',
},
].concat(webpackConfig.module.preLoaders);
karmaConfig.plugins.push('karma-coverage');
karmaConfig.coverageReporter = {
dir: '../coverage',
reporters: options.coverageReporters || [
{type: 'text'},
{type: 'html'},
],
};
karmaConfig.reporters.push('coverage');
}
if (options.notify) {
karmaConfig.reporters.push('notify');
karmaConfig.plugins.push('karma-notify-reporter');
}
karmaConfig.webpack = webpackConfig;
return karmaConfig;
};