forked from tidepool-org/blip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
82 lines (76 loc) · 1.93 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
const webpack = require('webpack');
const _ = require('lodash');
const optional = require('optional');
const webpackConf = require('./webpack.config.js');
const mochaConf = optional('./config/mocha.opts.json') || {};
const watch = process.env.npm_lifecycle_script.indexOf('--no-single-run') !== -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',
}),
],
});
delete testWebpackConf.devServer;
testWebpackConf.output = {
filename: '[name]',
};
testWebpackConf.mode = 'development';
module.exports = function karmaConfig(config) {
const defaultConfig = {
autoWatch: true,
browserNoActivityTimeout: 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: ['mocha', 'chai', 'sinon', 'intl-shim'],
logLevel: config.LOG_INFO,
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);
};