forked from naver/billboard.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
106 lines (93 loc) · 2.22 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
module.exports = function(config) {
const karmaConfig = {
frameworks: ["mocha", "chai", "sinon"],
files: [
"./node_modules/lite-fixture/index.js",
"./node_modules/hammer-simulator/index.js",
"./spec/assets/hammer-simulator.run.js",
"./src/scss/billboard.scss",
"./spec/assets/common.css",
"./spec/**/*-spec.js",
{
pattern: "./spec/assets/data/*",
watched: false,
included: false,
served: true
}
],
client: {
mocha: {
opts: "./mocha.opts"
}
},
webpack: {
devtool: "inline-source-map",
mode: "development",
stats: "none",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"@babel/preset-env", {
loose: true,
modules: false
}
]
],
plugins: ["add-module-exports"]
}
}
}
]
}
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./src/scss/billboard.scss": ["scss"],
"./spec/**/*-spec.js": config.coverage ? ["webpack"] : ["webpack", "sourcemap"],
},
scssPreprocessor: {
options: {
sourceMap: true,
outputStyle: "expanded",
}
},
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [],
reporters: ["mocha"],
colors: true,
webpackMiddleware: {
logLevel: "error"
},
// https://github.com/karma-runner/karma/blob/master/docs/config/01-configuration-file.md#browsernoactivitytimeout
browserNoActivityTimeout: 50000
};
karmaConfig.browsers.push(config.chrome ? "Chrome" : "ChromeHeadless");
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)/,
use: {
loader: "istanbul-instrumenter-loader",
query: {
esModules: true
}
}
});
karmaConfig.singleRun = true;
}
config.set(karmaConfig);
};