-
Notifications
You must be signed in to change notification settings - Fork 15
/
karma.conf.js
81 lines (68 loc) · 1.83 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
/* eslint-disable node/exports-style */
const merge = require('webpack-merge')
const commonWebpackConfig = require('./webpack.common')
const webpackConfig = merge(commonWebpackConfig, {
entry: null,
output: null,
devtool: 'inline-source-map',
mode: 'development'
})
if (webpackConfig.module && webpackConfig.module.rules) {
webpackConfig.module.rules
.forEach(rule => {
const isUseArray = Array.isArray(rule.use)
const uses = isUseArray ? [].concat(rule.use) : [ rule.use ]
uses.forEach((use, index) => {
if (use === 'babel-loader') {
const newUse = {
loader: 'babel-loader',
options: {
plugins: [
'rewire',
'istanbul'
]
}
}
if (isUseArray) {
rule.use[index] = newUse
} else {
rule.use = newUse
}
} else if (use.loader === 'babel-loader') {
use.options = use.options || {}
use.options.plugins = use.options.plugins || []
use.options.plugins.push('rewire')
use.options.plugins.push('istanbul')
}
})
})
}
module.exports = config => {
config.set({
files: [
'test/client/**/*.test.jsx',
'client/*/**/*.js{x,}',
'client/!(index|sound).jsx'
],
frameworks: [ 'mocha' ],
plugins: [
'karma-chrome-launcher',
'karma-coverage',
'karma-mocha',
'karma-mocha-reporter',
'karma-webpack'
],
preprocessors: {
'test/client/**/*.test.js{x,}': [ 'webpack' ],
'client/**/*.js{x,}': [ 'webpack' ]
},
reporters: [ 'mocha' ],
webpack: webpackConfig,
coverageReporter: {
type: process.env.CI ? 'lcovonly' : 'text',
dir: 'coverage/',
subdir: 'ui',
includeAllSources: true
}
})
}