-
Notifications
You must be signed in to change notification settings - Fork 5
/
karma.conf.js
123 lines (107 loc) · 3.27 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const ARUI_WEBPACK_TEMPLATE = require('arui-presets/webpack.base');
const IS_BENCHMARK = !!process.env.BENCHMARK;
const webpackConfig = merge.smart(ARUI_WEBPACK_TEMPLATE, {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
});
if (process.env.NODE_ENV !== 'production') {
merge.smart(webpackConfig, {
devtool: 'inline-source-map'
});
}
let babelLoaderConfig = webpackConfig.module.loaders.find(l => l.loader === 'babel-loader');
delete babelLoaderConfig.exclude;
module.exports = function (config) {
const cfg = {
browsers: ['PhantomJS_Desktop'],
singleRun: true,
plugins: [
require('karma-webpack'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-sourcemap-loader')
],
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true,
quiet: true
},
customLaunchers: {
PhantomJS_Desktop: {
base: 'PhantomJS',
options: {
viewportSize: {
width: 1280,
height: 100
}
}
}
},
browserNoActivityTimeout: 20000
};
if (!IS_BENCHMARK) {
cfg.webpack = merge.strategy({ 'module.loaders': 'append' })(
cfg.webpack,
{
module: { loaders: [
{
test: /\.jsx$/,
loader: 'isparta',
include: path.resolve('src')
}
] }
}
);
Object.assign(cfg, {
frameworks: ['mocha', 'chai-spies', 'chai-dom', 'chai'],
reporters: ['mocha', 'coverage', 'junit'],
preprocessors: {
'./src/*': ['webpack', 'sourcemap']
},
files: ['./src/*-test.js?(x)'],
coverageReporter: {
check: {
global: {
statements: 86,
branches: 80,
functions: 95,
lines: 40
}
}
},
junitReporter: {
outputFile: 'test-results.xml',
useBrowserName: false
}
});
cfg.plugins.push(
require('karma-mocha'),
require('karma-chai'),
require('karma-chai-spies'),
require('karma-chai-dom'),
require('karma-mocha-reporter'),
require('karma-junit-reporter'),
require('karma-coverage')
);
} else {
Object.assign(cfg, {
frameworks: ['benchmark'],
reporters: ['benchmark'],
preprocessors: {
'./src/*': ['webpack', 'sourcemap']
},
files: ['./src/*-benchmark.js?(x)']
});
cfg.plugins.push(
require('karma-bench'),
require('karma-benchmark-reporter')
);
}
config.set(cfg);
};