-
Notifications
You must be signed in to change notification settings - Fork 8
/
karma.conf.js
50 lines (37 loc) · 1.12 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
const karmaConstants = require('karma').constants
const _ = require('lodash')
const merge = require('webpack-merge')
module.exports = ({optionsForThisPlugin, webpackConfig, watch, junit}) => {
delete webpackConfig.entry
webpackConfig = merge(webpackConfig, {
devtool: optionsForThisPlugin.devtool || 'inline-source-map'
})
let karmaConfig = {
files: optionsForThisPlugin.files,
logLevel: karmaConstants.LOG_ERROR,
reporters: ['mocha'],
autoWatch: watch,
singleRun: !watch,
browsers: ['Chrome', 'Firefox'],
frameworks: ['mocha', 'chai'],
preprocessors: _(optionsForThisPlugin.files)
.map((filenameOrPattern) => [filenameOrPattern, ['webpack', 'sourcemap']])
.fromPairs()
.value(),
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only'
}
}
if (junit) {
karmaConfig.reporters.push('junit')
karmaConfig.junitReporter = {
outputDir: junit
}
}
if (optionsForThisPlugin.karmaConfig) {
// merge in karma config from project
Object.assign(karmaConfig, optionsForThisPlugin.karmaConfig)
}
return karmaConfig
}