-
Notifications
You must be signed in to change notification settings - Fork 4
/
karma.conf.cjs
100 lines (86 loc) · 2.21 KB
/
karma.conf.cjs
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
const karmaTestMiddleware = require('./test/helpers/karma-test-middleware.cjs')
const path = require('path')
// Reference: http://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function karmaConfig (config) {
config.set({
browsers: [
'Firefox',
// 'Chrome'
'ChromeHeadless'
],
singleRun: true,
autoWatch: true,
frameworks: [
// Reference: https://github.com/karma-runner/karma-mocha
// Set framework to mocha
'mocha',
'webpack'
],
reporters: ['progress'],
coverageIstanbulReporter: {
reports: ['text', 'html'],
fixWebpackSourcePaths: true
},
files: [
// Grab all files in the tests directory that contain _test.
'test/helpers/global.js',
'test/browser.test.js',
'test/Format.test.js',
'test/utils.test.js'
],
preprocessors: {
// Reference: http://webpack.github.io/docs/testing.html
// Reference: https://github.com/webpack/karma-webpack
// Convert files with webpack and load sourcemaps
'test/*.test.js': ['webpack', 'sourcemap']
},
// Configure code coverage reporter
coverageReporter: {
reporters: [
{ type: 'html', dir: 'coverage/' },
{ type: 'text' }
]
},
client: {
mocha: {
reporter: 'html',
opts: './test/mocha.opts'
}
},
middleware: ['test'],
plugins: [
'karma-mocha',
'karma-webpack',
'karma-spec-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-sourcemap-loader',
'karma-coverage',
{ 'middleware:test': ['factory', karmaTestMiddleware] }
],
// Test webpack config
webpack: {
module: {
rules: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'test')
],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
},
// Hide webpack build information from output
webpackMiddleware: {
noInfo: true
}
})
}