-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathkarma.conf.js
340 lines (311 loc) · 8.62 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
/* eslint-env es6 */
'use strict';
const DefinePlugin = require('webpack').DefinePlugin;
const SourceMapDevToolPlugin = require('webpack').SourceMapDevToolPlugin;
const path = require('path');
const packageDescriptor = require('./package.json');
let defaultBrowsers = ['Chrome'];
let startConnect = false;
const reporters = ['dots', 'jasmine-order'];
let buildId;
if (process.env.CI) {
buildId =
'CI #' +
process.env.GITHUB_RUN_NUMBER +
' (' +
process.env.GITHUB_RUN_ID +
')';
defaultBrowsers = [
'SL_EDGE',
'SL_CHROME',
// 'SL_FIREFOX',
// 'SL_ANDROID', Nuking for now
'SL_SAFARI'
];
reporters.push('saucelabs');
} else {
startConnect = true;
}
if (process.env.SAUCE_USERNAME) {
reporters.push('saucelabs');
}
const argv = require('yargs')
.array('browsers')
.default('browsers', defaultBrowsers)
.default('singleRun', true)
.default('testBasePath', '/src')
.default('coverage', true).argv;
const rules = [
{
test: /\.jsx?$/,
include: /src\/view/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/react',
['@babel/env', { targets: '> 0.25%, not dead' }]
],
plugins: ['@babel/plugin-proposal-class-properties']
}
}
},
{
test: /\.js$/,
include: /\.entries/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/env', { targets: '> 0.25%, not dead' }]]
}
}
},
{
test: /\.styl/,
include: /src\/view/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'stylus-loader' }
]
},
{
test: /\.css/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }]
},
{
test: /\.(jpe?g|png|gif)$/,
use: 'file-loader'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'file-loader'
}
];
if (argv.coverage) {
rules.push({
test: /\.jsx?$/,
enforce: 'post',
include: path.resolve('src/view'),
exclude: new RegExp('__tests__'),
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
});
rules.push({
test: /\.js$/,
enforce: 'pre',
include: path.resolve('src/lib'),
exclude: new RegExp('__tests__'),
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
});
reporters.push('coverage-istanbul');
}
module.exports = (config) => {
config.set({
hostname: '0.0.0.0',
// 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: ['webpack', 'jasmine', 'jasmine-matchers'],
// list of files / patterns to load in the browser
files: [
{
pattern: require.resolve('simulate'),
watched: false,
included: true,
served: true
},
{
pattern: path.join('helpers/*.js'),
watched: true,
included: true,
served: true
},
{
pattern: 'src/**/__tests__/**/*',
// When this is false, any change to the files in __test__ without the .test.js extension
// still triggers a re-run of tests. I don't know why but ultimately that's the result we
// want. When it's set to true, Karma starts getting messed up and running tests multiple
// times when such files are changed. o_O
// Sounds like https://github.com/webpack/karma-webpack/issues/44
watched: false,
included: false,
served: true
},
{
pattern: 'testIndex.js',
watched: false,
included: true,
served: true
}
],
// list of files to exclude
exclude: ['**/*.test.js'],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'testIndex.js': ['webpack']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: reporters,
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: argv.browsers,
customLaunchers: {
SL_CHROME: {
base: 'SauceLabs',
browserName: 'chrome',
browserVersion: 'latest',
platformName: 'Windows 10',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_FIREFOX: {
base: 'SauceLabs',
browserName: 'firefox',
browserVersion: 'latest',
platformName: 'Windows 10',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_SAFARI: {
base: 'SauceLabs',
browserName: 'safari',
browserVersion: 'latest',
platformName: 'macOS 11',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_IE10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platformName: 'Windows 7',
browserVersion: '10',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_IE11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platformName: 'Windows 7',
browserVersion: '11',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_EDGE: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
browserVersion: 'latest',
platformName: 'Windows 10',
'sauce:options': { screenResolution: '1600x1200' }
},
SL_IOS: {
base: 'SauceLabs',
deviceName: 'iPhone X Simulator',
appiumVersion: '1.19.1',
browserName: 'Safari',
platformName: 'iOS',
platformVersion: '14.0'
},
SL_ANDROID: {
base: 'SauceLabs',
deviceName: 'Android GoogleAPI Emulator',
appiumVersion: '1.18.1',
browserName: 'Chrome',
platformName: 'Android',
platformVersion: '11.0'
}
},
sauceLabs: {
buildId: buildId,
testName: packageDescriptor.name + ' Test',
tunnelIdentifier: 'github-action-tunnel',
startConnect: startConnect,
retryLimit: 3,
idleTimeout: 360,
recordVideo: false,
recordScreenshots: false,
// https://support.saucelabs.com/hc/en-us/articles/115010079868-Issues-with-Safari-and-Karma-Test-Runner
connectOptions: {
noSslBumpDomains: 'all'
}
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: argv.singleRun,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 5,
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
'report-config': {
html: {
subdir: 'html'
}
},
fixWebpackSourcePaths: true,
combineBrowserReports: true
},
captureTimeout: 60000,
browserDisconnectTimeout: 20000,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 300000,
webpack: {
devtool: false,
mode: 'development',
externals: {
window: 'window',
document: 'document'
},
resolve: {
alias: {
'@test-helpers': path.resolve(__dirname, 'src/view/__tests__/helpers')
},
extensions: ['.js', '.jsx']
},
module: {
rules: rules
},
plugins: [
new DefinePlugin({
TEST_BASE_PATH: JSON.stringify(process.cwd() + argv.testBasePath),
'process.browser': 'true',
'process.env.SCALE_MEDIUM': 'true',
'process.env.SCALE_LARGE': 'false',
'process.env.THEME_LIGHT': 'false',
'process.env.THEME_LIGHTEST': 'true',
'process.env.THEME_DARK': 'false',
'process.env.THEME_DARKEST': 'false'
}),
new SourceMapDevToolPlugin({})
]
},
client: {
jasmine: {
// seed: 55788
}
},
webpackServer: {
debug: false,
progress: true,
quiet: false
}
});
};