forked from isomorphic-git/isomorphic-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
310 lines (300 loc) · 9.13 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
// Karma configuration
const fs = require('fs')
process.env.CHROME_BIN = require('puppeteer').executablePath()
const path = require('path')
const webpack = require('webpack')
const branchOrPullRequestName =
process.env.TRAVIS_PULL_REQUEST === 'false'
? process.env.TRAVIS_BRANCH
: process.env.TRAVIS_PULL_REQUEST_SLUG +
'/' +
process.env.TRAVIS_PULL_REQUEST_BRANCH
module.exports = function (config) {
const options = {
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['FirefoxHeadless'],
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
beforeMiddleware: ['git-http-server'],
gitHttpServer: {
root: '__tests__/__fixtures__',
route: '/git-server'
},
// list of files / patterns to load in the browser
files: [
'__tests__/test-*.js',
{
pattern: '__tests__/__fixtures__/**/*',
served: true,
watched: false,
included: false
},
{
pattern: '__tests__/__fixtures__/**/.gitignore',
served: true,
watched: false,
included: false
}
],
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'__tests__/test-*.js': ['webpack']
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// Increase timeouts since some actions take quite a while.
browserNoActivityTimeout: 4 * 60 * 1000, // default 10000
// https://support.saucelabs.com/hc/en-us/articles/225104707-Karma-Tests-Disconnect-Particularly-When-Running-Tests-on-Safari
browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 0, // default 0
captureTimeout: 4 * 60 * 1000, // default 60000
// SauceLabs browsers
customLaunchers: {
XXXsl_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
extendedDebugging: true
},
XXXsl_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
extendedDebugging: true
},
sl_edge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge'
},
sl_safari: {
base: 'SauceLabs',
browserName: 'safari'
},
sl_ios_safari: {
base: 'SauceLabs',
deviceName: 'iPhone X Simulator',
platformName: 'iOS',
platformVersion: '11.2',
browserName: 'Safari',
appiumVersion: '1.7.2'
},
sl_android_chrome: {
base: 'SauceLabs',
deviceName: 'Android GoogleAPI Emulator',
platformName: 'Android',
platformVersion: '7.1',
browserName: 'Chrome',
appiumVersion: '1.7.2'
},
XXXbs_chrome_win: {
base: 'BrowserStack',
browser: 'Chrome',
browser_version: '62.0',
os: 'Windows',
os_version: '10'
},
XXXbs_firefox_win: {
base: 'BrowserStack',
browser: 'Firefox',
browser_version: '59.0',
os: 'Windows',
os_version: '10'
},
XXXbs_edge_win: {
base: 'BrowserStack',
browser: 'Edge',
browser_version: '16.0',
os: 'Windows',
os_version: '10'
},
XXXbs_chrome_mac: {
base: 'BrowserStack',
browser: 'Chrome',
browser_version: '62.0',
os: 'OS X',
os_version: 'High Sierra'
},
XXXbs_firefox_mac: {
base: 'BrowserStack',
browser: 'Firefox',
browser_version: '59.0',
os: 'OS X',
os_version: 'High Sierra'
},
XXXbs_safari_mac: {
base: 'BrowserStack',
browser: 'Safari',
browser_version: '11.1',
os: 'OS X',
os_version: 'High Sierra'
},
XXXbs_safari_iphone: {
base: 'BrowserStack',
real_mobile: true,
device: 'iPhone SE',
os: 'ios',
os_version: '11.2'
},
XXXbs_android: {
base: 'BrowserStack',
real_mobile: true,
device: 'Google Pixel',
os: 'android',
os_version: '8.0'
},
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless']
},
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
browserStack: {
project: 'isomorphic-git',
name: `isomorphic-git / ${branchOrPullRequestName} / ${
process.env.TRAVIS_COMMIT
}`,
build: process.env.TRAVIS_JOB_NUMBER + '-' + Date.now()
},
sauceLabs: {
// Since tags aren't being sent correctly, I'm going to stick the branch name in here.
testName: `isomorphic-git / ${branchOrPullRequestName} / ${
process.env.TRAVIS_COMMIT
}`,
// Note: I added the Date.now() bit so that when I can click "Restart" on a Travis job,
// Sauce Labs does not simply append new test results to the old set that failed, which
// convinces karma that it failed again and always.
build: process.env.TRAVIS_JOB_NUMBER + '-' + Date.now(),
// Note: it does not appear that tags are being sent correctly.
tags: [branchOrPullRequestName],
recordScreenshots: false,
recordVideo: false,
public: 'public restricted'
},
concurrency: 5,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// test results reporter to use
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['browsers', 'verbose', 'longest', 'pr-comment'],
longestSpecsToReport: 50,
browserify: {
transform: [
// Replace process.env.CI
'envify'
]
},
webpack: {
mode: 'development',
devtool: 'inline-source-map',
plugins: [new webpack.IgnorePlugin(/^(fs|jest-fixtures)$/)],
resolve: {
alias: {
'isomorphic-git/internal-apis': path.resolve(
__dirname,
'dist/internal.umd.min.js'
// 'src/internal-apis.js'
),
'isomorphic-git': path.resolve(
__dirname,
'dist/bundle.umd.min.js'
// 'src/index.js'
)
}
}
},
plugins: [
'karma-browserstack-launcher',
'karma-chrome-launcher',
'karma-edge-launcher',
'karma-fail-fast-reporter',
'karma-firefox-launcher',
'karma-git-http-server-middleware',
'karma-jasmine',
'karma-sauce-launcher',
'karma-verbose-reporter',
'karma-longest-reporter',
'karma-webpack',
{
'reporter:browsers': [
'type',
require('./__tests__/__helpers__/karma-successful-browsers-reporter')
]
},
{
'reporter:pr-comment': [
'type',
require('./__tests__/__helpers__/karma-pr-comment-reporter')
]
}
]
}
// Speed things up
if (process.env.FAILFAST) {
options.reporters.push('fail-fast')
}
if (!process.env.SAUCE_USERNAME) {
console.log(
'Skipping SauceLabs tests because SAUCE_USERNAME environment variable is not set.'
)
options.browsers.push('ChromeHeadlessNoSandbox')
} else if (!process.env.SAUCE_ACCESS_KEY) {
console.log(
'Skipping SauceLabs tests because SAUCE_ACCESS_KEY environment variable is not set.'
)
} else {
options.browsers = options.browsers.concat(
Object.keys(options.customLaunchers).filter(x => x.startsWith('sl_'))
)
options.reporters.push('saucelabs')
}
if (!process.env.BROWSER_STACK_USERNAME) {
console.log(
'Skipping BrowserStack tests because BROWSER_STACK_USERNAME environment variable is not set.'
)
} else if (!process.env.BROWSER_STACK_ACCESS_KEY) {
console.log(
'Skipping BrowserStack tests because BROWSER_STACK_ACCESS_KEY environment variable is not set.'
)
options.browsers.push('ChromeHeadlessNoSandbox')
} else {
options.browsers = options.browsers.concat(
Object.keys(options.customLaunchers).filter(x => x.startsWith('bs_'))
)
options.reporters.push('BrowserStack')
}
if (process.platform === 'win32') {
options.browsers.push('Edge')
}
// Only re-run browsers that failed in the previous run.
try {
const browsers = require('./successful-browsers.json')
console.log('skipping browsers:', browsers)
options.browsers = options.browsers.filter(b => !browsers.includes(b))
} catch (err) {
// nothing
}
console.log('running with browsers:', options.browsers)
if (options.browsers.length === 0) {
fs.unlinkSync('./successful-browsers.json')
process.exit(0)
}
if (!process.env.CI) {
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
options.singleRun = false
// enable / disable watching file and executing tests whenever any file changes
options.autoWatch = true
}
config.set(options)
}