This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
/
karma.conf.js
173 lines (163 loc) · 4.87 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
const bundleMode = require('minimist')(process.argv)['bundle-mode'] || 'dev'; // 'dev'|'perf'|undefined;
const karmaPlugins = require('minimist')(process.argv)['karma-plugins'] || undefined;
const mainFile = bundleMode === 'perf' ? 'test/onnx.perf.js' : 'test/onnx.dev.js';
// it's a known issue that Safari does not work with "localhost" in BrowserStack:
// https://www.browserstack.com/question/663
//
// we need to read machine IP address to replace "localhost":
// https://stackoverflow.com/a/8440736
//
function getMachineIpAddress() {
var os = require('os');
var ifaces = os.networkInterfaces();
for (const ifname in ifaces) {
for (const iface of ifaces[ifname]) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
continue;
}
// returns the first available IP address
return iface.address;
}
}
// if no available IP address, fallback to "localhost".
return 'localhost';
}
module.exports = function (config) {
config.set({
// global config of your BrowserStack account
browserStack: {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
forceLocal: true,
startTunnel: true,
},
frameworks: ['mocha'],
files: [
{ pattern: mainFile },
{ pattern: 'test/testdata-file-cache-*.json', included: false },
{ pattern: 'test/onnx-worker.js', included: false },
{ pattern: 'test/data/**/*', included: false, nocache: true },
{ pattern: 'deps/data/data/test/**/*', included: false, nocache: true },
{ pattern: 'deps/onnx/onnx/backend/test/data/**/*', included: false, nocache: true },
{ pattern: 'dist/onnx-wasm.wasm', included: false },
],
proxies: {
'/onnx-wasm.wasm': '/base/dist/onnx-wasm.wasm',
'/onnx-worker.js': '/base/test/onnx-worker.js',
},
plugins: karmaPlugins,
client: { captureConsole: true, mocha: { expose: ['body'], timeout: 60000 } },
preprocessors: { mainFile: ['sourcemap'] },
reporters: ['mocha', 'BrowserStack'],
browsers: [],
captureTimeout: 120000,
reportSlowerThan: 100,
browserDisconnectTimeout: 600000,
browserNoActivityTimeout: 300000,
browserDisconnectTolerance: 0,
browserSocketTimeout: 60000,
hostname: getMachineIpAddress(),
customLaunchers: {
ChromeTest: { base: 'Chrome', flags: ['--window-size=1,1'] },
ChromeDebug: { debug: true, base: 'Chrome', flags: ['--remote-debugging-port=9333'] },
//
// ==== BrowserStack browsers ====
//
// Windows
//
BS_WIN_10_Chrome_73: {
base: 'BrowserStack',
browser: 'Chrome',
browser_version: '73.0',
os: 'Windows',
os_version: '10',
},
BS_WIN_10_Edge_18: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'Edge',
browser_version: '18.0',
},
BS_WIN_10_Firefox_66: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'Firefox',
browser_version: '66.0',
},
BS_WIN_7_Chrome_63: {
base: 'BrowserStack',
browser: 'Chrome',
browser_version: '63.0',
os: 'Windows',
os_version: '7',
},
// macOS
//
BS_MAC_10_14_Safari_12: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Mojave',
browser: 'Safari',
browser_version: '12.0',
},
BS_MAC_10_14_Chrome_73: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Mojave',
browser: 'Chrome',
browser_version: '73.0',
},
BS_MAC_10_13_Safari_11_1: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'High Sierra',
browser: 'Safari',
browser_version: '11.1',
},
// iPhone
//
BS_IOS_12_1_iPhoneXS: {
base: 'BrowserStack',
device: 'iPhone XS',
real_mobile: true,
os: 'ios',
os_version: '12.1',
},
BS_IOS_11_iPhoneX: {
base: 'BrowserStack',
device: 'iPhone X',
real_mobile: true,
os: 'ios',
os_version: '11',
},
BS_IOS_10_3_iPhone7: {
base: 'BrowserStack',
device: 'iPhone 7',
real_mobile: true,
os: 'ios',
os_version: '10.3',
},
// Android
//
BS_ANDROID_9_Pixel_3: {
base: 'BrowserStack',
device: 'Google Pixel 3',
real_mobile: true,
os: 'android',
os_version: '9.0',
},
BS_ANDROID_7_1_Galaxy_Note_8: {
base: 'BrowserStack',
device: 'Samsung Galaxy Note 8',
real_mobile: true,
os: 'android',
os_version: '7.1',
},
}
});
};