forked from snabbdom/snabbdom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
karma.conf.js
78 lines (72 loc) · 2.14 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
const ci = !!process.env.CI;
const watch = !!process.env.WATCH;
const live = !!process.env.LIVE;
const es5 = !!process.env.ES5;
const ip = "bs-local.com";
const browserstack = require("./browserstack-karma.js");
// https://www.browserstack.com/open-source (text search "parallels")
// Instead of the 5 available we only use 2, so two commits can run CI at the same time
const BROWSERSTACK_OPEN_SOURCE_CONCURRENCY = 2;
const getBrowserstackBrowsers = () =>
Object.keys(browserstack).filter((k) => !!browserstack[k].es5 === es5);
const browsers = ci
? getBrowserstackBrowsers()
: live
? undefined
: watch
? ["Chrome"]
: ["ChromeHeadless", "FirefoxHeadless"];
module.exports = function (config) {
config.set({
basePath: ".",
frameworks: ["mocha", "karma-typescript"],
// list of files / patterns to load in the browser
files: process.env.FILES_PATTERN.split(",")
.map((p) => ({ pattern: p }))
.concat({ pattern: "src/**/*.ts" }),
preprocessors: {
"**/*.ts": "karma-typescript",
"**/*.tsx": "karma-typescript",
},
plugins: [
"karma-mocha",
"karma-typescript",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-browserstack-launcher",
],
hostname: ci ? ip : "localhost",
karmaTypescriptConfig: {
compilerOptions: {
...require("./tsconfig.json").compilerOptions,
...require("./test/tsconfig.json").compilerOptions,
sourceMap: false,
inlineSourceMap: true,
target: es5 ? "es5" : "es6",
},
bundlerOptions: {
sourceMap: true,
},
include: process.env.FILES_PATTERN.split(",").concat("src/**/*.ts"),
},
browserStack: {
name: "Snabbdom",
retryLimit: 1,
},
client: {
captureConsole: true,
},
customLaunchers: browserstack,
reporters: ["karma-typescript", "mocha", "BrowserStack"],
mochaReporter: {
showDiff: true,
},
port: 9876,
colors: true,
autoWatch: true,
browsers: browsers,
singleRun: !watch && !live,
concurrency: ci ? BROWSERSTACK_OPEN_SOURCE_CONCURRENCY : Infinity,
});
};