forked from webex/webrtc-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
364 lines (344 loc) · 8.86 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// eslint-disable-next-line
const typescriptTransform = require('karma-typescript-es6-transform');
// eslint-disable-next-line
process.env.CHROME_BIN = require('puppeteer').executablePath();
/**
* Karma runner configuration.
*
* @param config - Karma configuration.
*/
module.exports = (config) => {
const { SAUCE, SAUCE_USERNAME, SAUCE_ACCESS_KEY, TEST_TIMEOUT, BUILD_NUMBER, NODE_ENV } =
process.env;
const browsers = ['chrome'];
const appName = 'webrtc-core';
const environment = NODE_ENV || 'dev';
const buildNumber = BUILD_NUMBER || new Date().toUTCString();
const buildName = `${appName}-tests-${environment}#${buildNumber}`;
const useSauceConnect = SAUCE === 'true';
const timeout = TEST_TIMEOUT || 60000;
const sharedSauceOptions = {
screenResolution: '1600x1200',
extendedDebugging: true,
capturePerformance: true,
connectRetries: 2,
connectRetryTimeout: 2000,
};
const firefoxOptions = {
prefs: {
'devtools.chrome.enabled': true,
'devtools.debugger.prompt-connection': false,
'devtools.debugger.remote-enabled': true,
'dom.webnotifications.enabled': false,
'media.navigator.streams.fake': true,
'media.getusermedia.screensharing.enabled': true,
'media.navigator.permission.disabled': true,
'media.getusermedia.video.enabled': true,
'media.getusermedia.audio.enabled': true,
},
};
const chromeOptions = {
args: [
'start-maximized',
'disable-infobars',
'ignore-gpu-blacklist',
'test-type',
'disable-gpu',
'--no-sandbox',
'--disable-features=WebRtcHideLocalIpsWithMdns',
'--use-fake-device-for-media-stream',
'--use-fake-ui-for-media-stream',
'--enable-experimental-web-platform-features',
'--allow-insecure-localhost',
'--unsafely-treat-insecure-origin-as-secure',
],
};
const chromeSauceOptions = {
base: 'SauceLabs',
browserName: 'chrome',
'goog:chromeOptions': chromeOptions,
'sauce:options': {
...sharedSauceOptions,
tags: ['w3c-chrome'],
},
};
/**
* Utility method to create config object of all supported chrome versions on all supported platforms.
*
* @returns Sauce lab config object for chrome browser.
*/
const getChromeLaunchers = () => {
const chromeVersions = [
'80',
'81',
'83',
'84',
'85',
'86',
'87',
'88',
'89',
'90',
'91',
'92',
'93',
'94',
'95',
'96',
'97',
];
const platforms = ['Windows 10', 'macOS 11', 'macOS 12'];
const chromeLaunchers = {};
platforms.forEach((platform) => {
chromeVersions.forEach((version) => {
chromeLaunchers[`chrome_${version}_${platform}`] = {
...chromeSauceOptions,
browserVersion: version,
platformName: platform,
};
});
});
return chromeLaunchers;
};
const firefoxSauceOptions = {
base: 'SauceLabs',
browserName: 'firefox',
'moz:firefoxOptions': firefoxOptions,
'sauce:options': {
...sharedSauceOptions,
tags: ['w3c-firefox'],
},
};
/**
* Utility method to create config object of all supported firefox versions on all supported platforms.
*
* @returns Sauce lab config object for firefox browser.
*/
const getFirefoxLaunchers = () => {
const firefoxVersions = [
'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',
];
const platforms = ['Windows 10', 'Windows 11', 'macOS 11', 'macOS 12'];
const firefoxLaunchers = {};
platforms.forEach((platform) => {
firefoxVersions.forEach((version) => {
firefoxLaunchers[`firefox_${version}_${platform}`] = {
...firefoxSauceOptions,
browserVersion: version,
platformName: platform,
};
});
});
return firefoxLaunchers;
};
const safariSauceOptions = {
base: 'SauceLabs',
browserName: 'Safari',
'sauce:options': {
...sharedSauceOptions,
tags: ['w3c-safari'],
},
};
/**
* Utility method to create config object of all supported safari versions on all supported platforms.
*
* @returns Sauce lab config object for safari browser.
*/
const getSafariLaunchers = () => {
const safariLaunchers = {
'safari_14_macOS 11': {
...safariSauceOptions,
browserVersion: '14',
platformName: 'macOS 11',
},
'safari_15_macOS 12': {
...safariSauceOptions,
browserVersion: '15',
platformName: 'macOS 12',
},
};
return safariLaunchers;
};
const edgeSauceOptions = {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
'ms:edgeOptions': chromeOptions,
'sauce:options': {
...sharedSauceOptions,
tags: ['w3c-edge'],
},
};
/**
* Utility method to create config object of all supported edge versions on all supported platforms.
*
* @returns Sauce lab config object for edge browser.
*/
const getEdgeLaunchers = () => {
const edgeVersions = [
'80',
'81',
'83',
'84',
'85',
'86',
'87',
'88',
'89',
'90',
'91',
'92',
'93',
'94',
'95',
'96',
'97',
];
const platforms = ['Windows 10', 'Windows 11'];
const edgeLaunchers = {};
platforms.forEach((platform) => {
edgeVersions.forEach((version) => {
edgeLaunchers[`edge_${version}_${platform}`] = {
...edgeSauceOptions,
browserVersion: version,
platformName: platform,
};
});
});
return edgeLaunchers;
};
const localLaunchers = {
chrome: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
'--disable-web-security',
'--use-fake-device-for-media-stream',
'--use-fake-ui-for-media-stream',
],
},
firefox: {
base: 'Firefox',
flags: firefoxOptions.prefs,
},
safari: {
base: 'Safari',
flags: {
'webkit:WebRTC': {
DisableInsecureMediaCapture: true,
},
},
},
};
const chromeLaunchers = getChromeLaunchers();
const firefoxLaunchers = getFirefoxLaunchers();
const safariLaunchers = getSafariLaunchers();
const edgeLaunchers = getEdgeLaunchers();
if (useSauceConnect && !SAUCE_USERNAME && !SAUCE_ACCESS_KEY) {
// eslint-disable-next-line no-console
console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
process.exit(1);
}
const files = ['src/**/*.ts'];
const karmaConfig = {
basePath: '.',
frameworks: ['mocha', 'chai', 'karma-typescript'],
files,
preprocessors: {
'src/**/*.ts': ['karma-typescript'],
},
exclude: [],
reporters: ['junit', 'karma-typescript', 'saucelabs', 'mocha', 'coverage'],
port: 9876,
logLevel: config.DEBUG,
autoWatch: false,
singleRun: true,
concurrency: Infinity,
timeout,
captureTimeout: 240000,
karmaTypescriptConfig: {
tsconfig: './tsconfig.json',
compilerOptions: {
allowJs: true,
module: 'commonjs',
resolveJsonModule: false,
},
bundlerOptions: {
debug: true,
addNodeGlobals: false,
entrypoints: config.integration ? /\.integration-test\.ts/i : /\.test\.ts$/i,
transforms: [typescriptTransform()],
},
coverageOptions: {
exclude: [/\.(d|spec|test)\.ts$/i],
},
},
sauceLabs: {
build: buildName,
recordScreenshots: true,
recordVideo: true,
tags: ['web-rtc-core'],
testName: `${config.integration ? 'Integration Tests' : 'Unit Tests'}`,
connectOptions: {
logfile: './sauce.log',
noSslBumpDomains: [
'idbroker.webex.com',
'idbrokerbts.webex.com',
'127.0.0.1',
'localhost',
'*.wbx2.com',
'*.ciscospark.com',
],
tunnelDomains: ['127.0.0.1', 'localhost'],
},
},
coverageReporter: {
type: 'html',
dir: 'coverage',
},
junitReporter: {
outputDir: 'coverage',
outputFile: 'junit.xml',
},
};
let sauceLaunchers = {};
if (useSauceConnect) {
if (config.chrome) {
sauceLaunchers = { ...chromeLaunchers };
} else if (config.firefox) {
sauceLaunchers = { ...firefoxLaunchers };
} else if (config.edge) {
sauceLaunchers = { ...edgeLaunchers };
} else if (config.safari) {
sauceLaunchers = { ...safariLaunchers };
}
}
karmaConfig.customLaunchers = { ...localLaunchers, ...sauceLaunchers };
karmaConfig.browsers = useSauceConnect ? Object.keys(sauceLaunchers) : browsers;
config.set(karmaConfig);
};