-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
235 lines (225 loc) · 5.85 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/* eslint-env node */
"use strict";
const thisPackage = require("./package");
// Minimal localConfig if there is not one locally.
let localConfig = {
browserStack: {},
};
try {
// eslint-disable-next-line import/no-unresolved, global-require
localConfig = require("./local_config");
}
catch (ex) {} // eslint-disable-line no-empty
module.exports = function karmaConfig(config) {
const options = {
basePath: "",
frameworks: ["requirejs", "mocha", "chai", "sinon"],
client: {
mocha: {
asyncOnly: true,
grep: config.grep,
},
},
files: [
"test/karma-main.js",
"node_modules/babel-polyfill/dist/polyfill.js",
{ pattern: "build/dist/last-resort.js", included: false },
{ pattern: "test/frame.html", included: false },
{ pattern: "test/!(karma-main).js", included: false },
{
pattern: "node_modules/bluebird/js/browser/bluebird.js",
included: false,
},
],
exclude: [],
preprocessors: {
"test/**/!(karma-main|frame_script|worker).js": ["babelModule"],
"test/@(karma-main|frame_script|worker).js": ["babel"],
},
customPreprocessors: {
babelModule: {
base: "babel",
options: {
plugins: ["@babel/plugin-transform-modules-amd"],
},
},
},
babelPreprocessor: {
options: {
presets: ["@babel/preset-env"],
ignore: [
"node_modules",
],
sourceMap: "inline",
},
filename: function filename(file) {
return file.originalPath.replace(/\.js$/, ".es5.js");
},
sourceFileName: function sourceFileName(file) {
return file.originalPath;
},
},
reporters: ["progress"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["ChromeHeadless", "FirefoxHeadless"],
browserStack: {
project: thisPackage.name,
},
customLaunchers: {
ChromeWin: {
base: "BrowserStack",
browser: "Chrome",
os: "Windows",
os_version: "10",
},
FirefoxWin: {
base: "BrowserStack",
browser: "Firefox",
os: "Windows",
os_version: "10",
},
IE11: {
base: "BrowserStack",
browser: "IE",
browser_version: "11",
os: "Windows",
os_version: "10",
},
IE10: {
base: "BrowserStack",
browser: "IE",
browser_version: "10",
os: "Windows",
os_version: "8",
},
IE9: {
base: "BrowserStack",
browser: "IE",
browser_version: "9",
os: "Windows",
os_version: "7",
},
Edge: {
base: "BrowserStack",
browser: "Edge",
os: "Windows",
os_version: "10",
},
Opera: {
base: "BrowserStack",
browser: "Opera",
os: "Windows",
os_version: "10",
},
SafariElCapitan: {
base: "BrowserStack",
browser: "Safari",
os: "OS X",
os_version: "El Capitan",
},
SafariYosemite: {
base: "BrowserStack",
browser: "Safari",
os: "OS X",
os_version: "Yosemite",
},
SafariMavericks: {
base: "BrowserStack",
browser: "Safari",
os: "OS X",
os_version: "Mavericks",
},
//
// Tunnel seems to fail on all nexus devices.
//
// Android5: {
// base: "BrowserStack",
// browser: "android",
// os: "android",
// device: "Google Nexus 6",
// os_version: "5.0",
// },
//
Android4_4: {
base: "BrowserStack",
browser: "android",
os: "android",
device: "Samsung Galaxy Tab 4 10.1",
os_version: "4.4",
},
iOS9_3: {
base: "BrowserStack",
browser: "iOS",
os: "iOS",
device: "iPhone 6S",
os_version: "9.3",
},
iOS5: {
base: "BrowserStack",
browser: "iOS",
os: "iOS",
device: "iPhone 5",
os_version: "6.0",
},
//
// Fails on this platform, in workers. It is unclear why. Could just as
// well being iSO 5.1 that is unable to pass errors properly to an onerror
// handler set in a worker.
//
// iPhone4S: {
// base: "BrowserStack",
// browser: "iOS",
// os: "iOS",
// device: "iPhone 4S",
// os_version: "5.1",
// },
//
// Karma cannot connect on this platform...
//
// iPhone4: {
// base: "BrowserStack",
// browser: "iOS",
// os: "iOS",
// device: "iPhone 4",
// os_version: "4.0",
// },
//
// Tunnel seems to fail on this device.
//
// WindowsPhone8_1: {
// base: "BrowserStack",
// browser: "winphone",
// os: "winphone",
// device: "Nokia Lumia 520",
// os_version: "8.1",
// },
},
singleRun: false,
concurrency: 2,
};
// Merge the browserStack configuration we got with the base values in our
// config.
Object.assign(options.browserStack, localConfig.browserStack);
const { browsers } = config;
if (browsers.length === 1 && browsers[0] === "all") {
const newList = options.browsers.concat(Object.keys(options.customLaunchers));
// Yes, we must modify this array in place.
// eslint-disable-next-line prefer-spread
browsers.splice.apply(browsers, [0, browsers.length].concat(newList));
}
const found = browsers.some((x) => {
const custom = options.customLaunchers[x];
return custom && custom.base === "BrowserStack";
});
if (found) {
options.captureTimeout = 3e5;
options.browserNoActivityTimeout = 3e5;
options.browserDisconnectTimeout = 3e5;
options.browserDisconnectTolerance = 3;
options.client.slow = true;
}
config.set(options);
};