forked from APIDevTools/json-schema-ref-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.cjs
78 lines (65 loc) · 1.96 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
// Karma config
// https://karma-runner.github.io/0.12/config/configuration-file.html
// https://jstools.dev/karma-config/
"use strict";
const nodeUtil = require("util");
const { buildConfig } = require("@jsdevtools/karma-config");
const { host } = require("@jsdevtools/host-environment");
module.exports = (karma) => {
const browsers = [];
const CI = isCI();
browsers.push(CI ? "ChromeHeadless" : "Chrome");
browsers.push(CI ? "FirefoxHeadless" : "Firefox");
host.os.mac && browsers.push("Safari");
host.os.windows && browsers.push("Edge");
const plugins = [
require("@jsdevtools/karma-host-environment"),
require("karma-verbose-reporter"),
require("karma-mocha"),
require("karma-webpack"),
]
plugins.push(require("karma-chrome-launcher"))
plugins.push(require("karma-firefox-launcher"))
host.os.mac && plugins.push(require("karma-safari-launcher"))
host.os.windows && plugins.push(require("@chiragrupani/karma-chromium-edge-launcher"))
plugins.push(require("karma-coverage-istanbul-reporter"))
const config = buildConfig({
sourceDir: "lib",
fixtures: "test/fixtures/**/*.js",
browsers: {
chrome: true,
firefox: true,
safari: host.os.mac,
edge: host.os.windows,
ie: false
},
config: {
browsers: browsers,
plugins: plugins
}
});
config.files.push({
pattern: "test/**/*.js",
type: "module"
});
if (config.logLevel !== karma.LOG_DISABLE) {
console.debug("Karma Config:\n", nodeUtil.inspect(config, {
depth: 10,
colors: true,
compact: false,
}));
}
karma.set(config);
};
function isCI() {
let CI = environmentFlag("CI");
let karmaCI = environmentFlag("KARMA_CI");
return Boolean(CI || karmaCI || host.ci);
};
function environmentFlag(name) {
let value = environmentVariable(name);
return !["", "false", "off", "no"].includes(value);
}
function environmentVariable(name) {
return (process.env[name] || "").trim().toLowerCase();
}