-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathkarma.conf.js
106 lines (99 loc) · 2.53 KB
/
karma.conf.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const webpack = require('webpack');
const _ = require('lodash');
const optional = require('optional');
const webpackConf = require('./webpack.config.js');
const mochaConf = optional('./config/mocha.opts.json') || { timeout: 8000 };
const watch = process.env.WATCH_MODE === 1;
const testWebpackConf = _.assign({}, webpackConf, {
devtool: watch ? false : 'inline-cheap-module-source-map',
plugins: [
new webpack.DefinePlugin({
__DEV__: false,
__TEST__: true,
__PROD__: false,
__I18N_ENABLED__: 'false',
__DEV_TOOLS__: false,
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser.js',
}),
],
});
testWebpackConf.externals = {
cheerio: 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true,
};
delete testWebpackConf.devServer;
delete testWebpackConf.entry;
delete testWebpackConf.output.filename;
testWebpackConf.mode = 'development';
module.exports = function karmaConfig(config) {
const defaultConfig = {
autoWatch: true,
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 60000,
pingTimeout: 60000,
browsers: ['CustomChromeHeadless'],
captureTimeout: 60000,
client: {
mocha: mochaConf,
},
colors: true,
concurrency: Infinity,
coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'html' },
{ type: 'text' },
],
},
customLaunchers: {
CustomChromeHeadless: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox',
'--remote-debugging-port=9222',
],
},
},
files: [
'loadtests.js',
],
frameworks: ['webpack', 'mocha', 'chai', 'sinon', 'intl-shim'],
logLevel: config.LOG_INFO,
plugins: [
'karma-webpack',
'karma-sourcemap-loader',
'karma-mocha',
'karma-mocha-reporter',
'karma-chai',
'karma-sinon',
'karma-intl-shim',
'karma-chrome-launcher',
'karma-coverage',
],
preprocessors: {
'loadtests.js': ['webpack', 'sourcemap'],
},
reporters: ['mocha', 'coverage'],
singleRun: true,
mochaReporter: {
showDiff: true,
},
webpack: testWebpackConf,
webpackMiddleware: {
noInfo: true,
stats: 'errors-only',
},
};
if(watch) { //remove test coverage for test-watch
delete defaultConfig.coverageReporter;
defaultConfig.reporters = ['mocha'];
}
config.set(defaultConfig);
};