/
index.js
58 lines (57 loc) · 1.47 KB
/
index.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
const path = require('path')
module.exports = (config, webpackConfig) => {
const { specFiles, fixtureDocs, mode } = config
const karmaConfig = {
files: [
{
pattern: specFiles,
watched: false
},
fixtureDocs
],
exclude: [],
preprocessors: {
[specFiles]: ['webpack'],
[fixtureDocs]: ['html2js']
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
frameworks: ['mocha', 'fixture', 'sinon', 'power-assert'],
reporters: ['mocha', 'coverage'],
coverageReporter: {
type: 'lcov',
dir: path.join(process.cwd(), './coverage'),
subdir: 'report',
file: path.join(process.cwd(), './coverage/report/lcov.info')
},
browsers: ['CustomHeadless', 'CustomChrome'],
customLaunchers: {
CustomHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--remote-debugging-port=9222']
},
CustomChrome: {
base: 'Chrome',
flags: ['--no-sandbox', '--ignore-certificate-errors', '--remote-debugging-port=9222']
}
},
captureTimeout: 60000,
singleRun: true
}
// If mode value is `watch`,
if (mode === 'watch') {
karmaConfig.coverageReporter = {
type: 'text-summary'
}
karmaConfig.singleRun = false
}
if (mode === 'debug') {
karmaConfig.browsers = ['CustomChrome']
karmaConfig.singleRun = false
} else {
karmaConfig.browsers = ['CustomHeadless']
}
return karmaConfig
}