-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkarma.conf.js
More file actions
64 lines (61 loc) · 1.87 KB
/
karma.conf.js
File metadata and controls
64 lines (61 loc) · 1.87 KB
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
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
// Auto-detect Chrome/Chromium binary if CHROME_BIN is not set
if (!process.env.CHROME_BIN) {
const fs = require("fs");
const candidates = [
"/usr/bin/chromium", // Arch, Alpine
"/usr/bin/chromium-browser", // Fedora, Debian/Ubuntu
"/usr/bin/google-chrome-stable",
"/usr/bin/google-chrome",
];
process.env.CHROME_BIN =
candidates.find((p) => fs.existsSync(p)) || "chromium";
}
module.exports = function (config) {
const isCi =
process.env.CI === "true" || process.env.KARMA_SINGLE_RUN === "true";
const headless = isCi || process.env.CHROME_HEADLESS === "true";
const browsers = headless ? ["ChromeHeadless"] : ["Chrome"];
// Include 'coverage' reporter so karma-coverage emits files (html/json-summary)
const reporters = headless
? ["progress", "coverage"]
: ["progress", "kjhtml", "coverage"];
config.set({
basePath: "",
frameworks: ["jasmine"],
plugins: [
require("karma-jasmine"),
require("karma-chrome-launcher"),
require("karma-jasmine-html-reporter"),
require("karma-coverage"),
],
client: {
jasmine: {
random: false,
},
clearContext: !headless, // keep reporter UI only when not headless
},
jasmineHtmlReporter: {
suppressAll: true,
},
coverageReporter: {
dir: require("path").join(__dirname, "./coverage/datasync"),
subdir: ".",
// Add json-summary so Makefile coverage-check can read coverage-summary.json
reporters: [
{ type: "html" },
{ type: "text-summary" },
{ type: "json-summary" },
],
},
reporters,
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: !isCi,
browsers,
singleRun: isCi,
restartOnFileChange: !isCi,
});
};