-
-
Notifications
You must be signed in to change notification settings - Fork 315
/
karma.conf.js
295 lines (279 loc) · 11.4 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
/**
* @since 2.2.0
*/
process.traceDeprecation = true;
process.env.BABEL_ENV = 'test';
const path = require('path');
require('@babel/register');
let ci = process.env.CI || process.env.APPVEYOR;
let webpackConfig = require('./build-config/webpack.prod.main.js');
let support_dir = path.resolve(__dirname, 'test', 'support');
let fakeAudioStream = path.join(support_dir, 'Front_Center.wav');
let fakeVideoStream = path.join(support_dir, 'bus_qcif_7.5fps.y4m');
//-------------------------------------------
// Chrome CLI options
//-------------------------------------------
// http://peter.sh/experiments/chromium-command-line-switches/
const chromeFlags = [
'--no-sandbox',
'--disable-gpu',
'--no-first-run',
'--noerrdialogs',
'--no-default-browser-check',
'--use-fake-device-for-media-stream',
'--use-fake-ui-for-media-stream',
'--use-file-for-fake-audio-capture=' + fakeAudioStream,
'--use-file-for-fake-video-capture=' + fakeVideoStream,
'--autoplay-policy=no-user-gesture-required',
'--user-data-dir=' + path.resolve('.chrome'),
'--disable-translate',
'--disable-extensions',
'--disable-infobars',
'--ignore-certificate-errors',
'--allow-insecure-localhost',
'--enable-experimental-web-platform-features',
'--js-flags=--max-old-space-size=8196'
];
//-------------------------------------------
// Firefox CLI options
//-------------------------------------------
const firefoxFlags = {
'media.navigator.permission.disabled': true,
'media.navigator.streams.fake': true,
'media.getusermedia.screensharing.enabled': true,
'media.setsinkid.enabled': true,
'javascript.options.streams': true,
// devtools
'devtools.theme': 'dark',
'devtools.webconsole.timestampMessages': true,
'devtools.toolbox.host': 'right',
'devtools.toolbox.selectedTool': 'webconsole',
'devtools.chrome.enabled': true,
// disable autoplay blocking, see:
// https://www.ghacks.net/2018/09/21/firefox-improved-autoplay-blocking/
'media.autoplay.default': 1,
'media.autoplay.ask-permission': false,
'media.autoplay.enabled.user-gestures-needed': false,
'media.autoplay.block-webaudio': false,
// disable update and startup
'extensions.update.enabled': false,
'app.update.enabled': false,
'browser.startup.page': 0,
'startup.homepage_welcome_url': '',
'browser.shell.checkDefaultBrowser': false
};
module.exports = function(config) {
let configuration = {
basePath: '',
frameworks: ['jasmine', 'jasmine-matchers', 'host-environment', 'detectBrowsers', 'webpack'],
hostname: 'localhost',
port: 9876,
logLevel: config.LOG_INFO,
singleRun: true, // enable for headless testing
autoWatch: false,
files: [
// -------------------------------------------
// demo files
// -------------------------------------------
{
pattern: 'test/support/*',
included: false,
watched: false,
served: true
},
// style
'node_modules/video.js/dist/video-js.css',
'node_modules/videojs-wavesurfer/dist/css/videojs.wavesurfer.css',
// library dependencies
'node_modules/video.js/dist/video.js',
'node_modules/webrtc-adapter/out/adapter.js',
'node_modules/recordrtc/RecordRTC.js',
// -------------------------------------------
// third-party dependencies for audio-only
// -------------------------------------------
// wavesurfer.js
'node_modules/wavesurfer.js/dist/wavesurfer.min.js',
'node_modules/wavesurfer.js/dist/plugin/wavesurfer.microphone.js',
// videojs-wavesurfer
'node_modules/videojs-wavesurfer/dist/videojs.wavesurfer.js',
// -------------------------------------------
// plugin style
// -------------------------------------------
'dist/css/videojs.record.css',
// -----------------------------------------------
// third-party dependencies for (optional) plugins
// -----------------------------------------------
// recorder.js
'node_modules/recorderjs/dist/recorder.js',
// libvorbis.js
'node_modules/libvorbis.js/js/libvorbis.min.js',
// lamejs
{pattern: 'node_modules/lamejs/worker-example/*worker*.js', included: false, served: true},
'node_modules/lamejs/lame.min.js',
// opus-recorder
{pattern: 'node_modules/opus-recorder/dist/*Worker.min.js', included: false, served: true},
{pattern: 'node_modules/opus-recorder/dist/*.wasm', included: false, served: true, type: 'wasm'},
'node_modules/opus-recorder/dist/recorder.min.js',
// opus-media-recorder
{pattern: 'node_modules/opus-media-recorder/encoderWorker.umd.js', included: false, served: true},
{pattern: 'node_modules/opus-media-recorder/*.wasm', included: false, served: true, type: 'wasm'},
// vmsg
{pattern: 'node_modules/vmsg/*.wasm', included: false, served: true, type: 'wasm'},
// web streams API polyfill to support Firefox (for webm-wasm)
'node_modules/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js',
// webm-wasm
{pattern: 'node_modules/webm-wasm/dist/webm-worker.js', included: false, served: true},
{pattern: 'node_modules/webm-wasm/dist/webm-wasm.wasm', included: false, served: true, type: 'wasm'},
// ffmpeg.js
{pattern: 'node_modules/ffmpeg.js/ffmpeg-worker-mp4.js', included: false, served: true},
// ffmpeg.wasm
{pattern: 'node_modules/@ffmpeg/ffmpeg/dist/ffmpeg.min.js', included: false, served: true},
{pattern: 'node_modules/@ffmpeg/core/dist/ffmpeg-core.js', included: false, served: true},
// gif-recorder: only available on CDN
'https://cdn.webrtc-experiment.com/gif-recorder.js',
// -------------------------------------------
// specs
// -------------------------------------------
{pattern: 'test/**/*.spec.js', watched: false}
],
// for CDN scripts
crossOriginAttribute: false,
proxies: {
// necessary workaround for opus-recorder plugin
'/encoderWorker.min.js': '/base/node_modules/opus-recorder/dist/encoderWorker.min.js',
'/encoderWorker.min.wasm': '/base/node_modules/opus-recorder/dist/encoderWorker.min.wasm'
},
mime: {
'application/wasm': ['wasm']
},
preprocessors: {
'test/**/*.spec.js': ['webpack'],
// source files to generate coverage for,
// do not include tests or libraries
'src/js/**/*.js': ['coverage']
},
webpackMiddleware: {
stats: 'errors-only'
},
plugins: [
'karma-webpack',
'karma-jasmine',
'karma-jasmine-matchers',
'karma-chrome-launcher',
'karma-firefox-launcher',
'@chiragrupani/karma-chromium-edge-launcher',
'karma-coverage',
'karma-verbose-reporter',
'karma-host-environment',
'karma-detect-browsers'
],
detectBrowsers: {
enabled: true,
usePhantomJS: false,
preferHeadless: true,
postDetection: function(availableBrowsers) {
if (availableBrowsers.length > 1) {
// use custom browser launchers
let result = availableBrowsers;
let cr = availableBrowsers.indexOf('Chrome');
if (cr > -1) {
availableBrowsers[cd] = 'Chrome_dev';
}
let cd = availableBrowsers.indexOf('ChromeHeadless');
if (cd > -1) {
availableBrowsers[cd] = 'Chrome_headless';
}
let fd = availableBrowsers.indexOf('FirefoxHeadless');
if (fd > -1) {
availableBrowsers[fd] = 'Firefox_headless';
}
let fh = availableBrowsers.indexOf('Firefox');
if (fh > -1) {
availableBrowsers[fh] = 'Firefox_dev';
}
let ch = availableBrowsers.indexOf('ChromiumHeadless');
if (ch > -1) {
availableBrowsers[ch] = 'Chromium_dev';
}
let ce = availableBrowsers.indexOf('Chromium');
if (ce > -1) {
availableBrowsers[ce] = 'Chromium_dev';
}
// ignore IE
let ie = availableBrowsers.indexOf('IE');
if (ie > -1) {
availableBrowsers.splice(ie, 1);
}
// ignore Safari (until it's supported...)
let safariTechPreview = availableBrowsers.indexOf('SafariTechPreview');
if (safariTechPreview > -1) {
availableBrowsers.splice(safariTechPreview, 1);
}
let safari = availableBrowsers.indexOf('Safari');
if (safari > -1) {
availableBrowsers.splice(safari, 1);
}
return result;
}
}
},
captureConsole: true,
concurrency: 1,
browserSocketTimeout: 20000,
browserDisconnectTimeout : 10000,
browserDisconnectTolerance : 1,
browserNoActivityTimeout : 60000,
colors: true,
reporters: ['verbose', 'progress', 'coverage'],
coverageReporter: {
dir: 'coverage',
reporters: [
{ type: 'html', subdir: 'html' },
{ type: 'lcov', subdir: 'lcov' }
]
},
webpack: webpackConfig,
customLaunchers: {
Chrome_dev: {
base: 'Chrome',
flags: chromeFlags,
chromeDataDir: path.resolve(__dirname, '.chrome')
},
Chrome_headless: {
base: 'ChromeHeadless',
flags: chromeFlags
},
Chromium_dev: {
base: 'ChromiumHeadless',
flags: chromeFlags
},
Firefox_dev: {
base: 'Firefox',
prefs: firefoxFlags
},
Firefox_headless: {
base: 'FirefoxHeadless',
prefs: firefoxFlags
},
Edge_dev: {
base: 'Edge',
flags: chromeFlags,
chromeDataDir: path.resolve(__dirname, '.edge')
},
Edge_headless: {
base: 'EdgeHeadless',
flags: chromeFlags,
chromeDataDir: path.resolve(__dirname, '.edge')
}
}
};
if (ci) {
configuration.browsers = ['Firefox_headless', 'Chrome_headless'];
configuration.singleRun = true;
configuration.detectBrowsers.enabled = false;
if (process.env.APPVEYOR) {
configuration.browsers.push('Edge_headless');
}
}
config.set(configuration);
};