-
Notifications
You must be signed in to change notification settings - Fork 10
/
karma.conf.js
82 lines (75 loc) · 1.79 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
module.exports = config => {
const karmaConfig = {
frameworks: ["mocha", "chai", "sinon"],
// list of files / patterns to load in the browser
files: [
"./node_modules/lite-fixture/index.js",
"./test/unit/**/*.spec.js",
],
client: {
mocha: {
opts: "./mocha.opts",
},
},
webpack: {
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
"presets": [
[
"@babel/preset-env",
{
"loose": true,
"modules": "commonjs",
"targets": {"chrome": "55"},
},
],
],
"plugins": [
"add-module-exports",
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
],
},
},
],
},
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./test/**/*.spec.js": config.coverage ? ["webpack"] : ["webpack", "sourcemap"],
},
browsers: [],
customLaunchers: {
CustomChromeHeadless: {
base: "ChromeHeadless",
flags: ["--disable-gpu", "--no-sandbox"],
},
},
reporters: ["mocha"],
webpackMiddleware: {
noInfo: true,
},
};
karmaConfig.browsers.push(config.chrome ? "Chrome" : "CustomChromeHeadless");
if (config.coverage) {
karmaConfig.reporters.push("coverage-istanbul");
karmaConfig.coverageIstanbulReporter = {
reports: ["text-summary", "html", "lcovonly"],
dir: "./coverage",
};
karmaConfig.webpack.module.rules.unshift({
test: /\.js$/,
exclude: /(node_modules|test)/,
loader: "istanbul-instrumenter-loader",
});
karmaConfig.singleRun = true;
}
config.set(karmaConfig);
};