@webex/test-helper-mocha 2.37.0 → 2.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +36 -26
package/dist/index.js
CHANGED
|
@@ -1,87 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
6
|
-
|
|
7
5
|
var _isNan = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/number/is-nan"));
|
|
8
|
-
|
|
9
6
|
/*!
|
|
10
7
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
11
8
|
*/
|
|
12
9
|
|
|
13
|
-
/* globals window */
|
|
14
10
|
var bowser = require('bowser');
|
|
11
|
+
|
|
15
12
|
/**
|
|
16
13
|
* Indicates if we're running in node
|
|
17
14
|
* @returns {boolean}
|
|
18
15
|
* @private
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
17
|
function inNode() {
|
|
23
18
|
return typeof window === 'undefined';
|
|
24
19
|
}
|
|
20
|
+
|
|
25
21
|
/**
|
|
26
22
|
* Indicates if we're running in a web browser
|
|
27
23
|
* @returns {boolean}
|
|
28
24
|
* @private
|
|
29
25
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
26
|
function inBrowser() {
|
|
33
27
|
return !inNode();
|
|
34
28
|
}
|
|
29
|
+
|
|
35
30
|
/**
|
|
36
31
|
* Indicates if we are running in the named browser
|
|
37
32
|
* @param {string} name name of the browser
|
|
38
33
|
* @returns {boolean}
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
35
|
function inSpecificBrowser(name) {
|
|
43
36
|
return window && bowser.getParser(window.navigator.userAgent).isBrowser(name);
|
|
44
37
|
}
|
|
38
|
+
|
|
45
39
|
/**
|
|
46
40
|
* Indicates if we're running in firefox
|
|
47
41
|
* @returns {boolean}
|
|
48
42
|
* @private
|
|
49
43
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
44
|
function inFirefox() {
|
|
53
45
|
return inSpecificBrowser('firefox');
|
|
54
46
|
}
|
|
47
|
+
|
|
55
48
|
/**
|
|
56
49
|
* Indicates if we're running in safari
|
|
57
50
|
* @returns {boolean}
|
|
58
51
|
* @private
|
|
59
52
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
53
|
function inSafari() {
|
|
63
54
|
return inSpecificBrowser('safari');
|
|
64
55
|
}
|
|
56
|
+
|
|
65
57
|
/**
|
|
66
58
|
* Indicates if we're running on Jenkins
|
|
67
59
|
* @returns {boolean}
|
|
68
60
|
* @private
|
|
69
61
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
62
|
function inJenkins() {
|
|
73
63
|
return process.env.JENKINS;
|
|
74
64
|
}
|
|
65
|
+
|
|
75
66
|
/**
|
|
76
67
|
* noop
|
|
77
68
|
* @returns {undefined}
|
|
78
69
|
* @private
|
|
79
70
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
function noop() {// intentionally empty
|
|
71
|
+
function noop() {
|
|
72
|
+
// intentionally empty
|
|
83
73
|
}
|
|
84
|
-
|
|
85
74
|
module.exports = {
|
|
86
75
|
/**
|
|
87
76
|
* Wrap the desired mochaMethod with `flaky` to indicate it's a flaky test
|
|
@@ -98,11 +87,9 @@ module.exports = {
|
|
|
98
87
|
if (!mochaMethod.skip) {
|
|
99
88
|
return mochaMethod;
|
|
100
89
|
}
|
|
101
|
-
|
|
102
90
|
var shouldSkip = envVar && envVar !== 'false' && !!envVar;
|
|
103
91
|
return shouldSkip ? mochaMethod.skip : mochaMethod;
|
|
104
92
|
},
|
|
105
|
-
|
|
106
93
|
/**
|
|
107
94
|
* A lot of failures get produced by EventEmitters, which makes them difficult to
|
|
108
95
|
* detect in tests (they just look like timeouts). This is a test helper that
|
|
@@ -117,34 +104,32 @@ module.exports = {
|
|
|
117
104
|
r = reject;
|
|
118
105
|
emitter.once('error', reject);
|
|
119
106
|
});
|
|
120
|
-
|
|
121
107
|
var handler = _promise.default.race([p, fn(emitter)]).then(unbind).catch(function (reason) {
|
|
122
108
|
unbind();
|
|
123
109
|
throw reason;
|
|
124
|
-
});
|
|
125
|
-
|
|
110
|
+
});
|
|
126
111
|
|
|
112
|
+
// Make it possible to add additional emitters
|
|
127
113
|
handler.add = function (e) {
|
|
128
114
|
return e.once('error', r);
|
|
129
115
|
};
|
|
130
|
-
|
|
131
116
|
return handler;
|
|
117
|
+
|
|
132
118
|
/**
|
|
133
119
|
* unbinder
|
|
134
120
|
* @private
|
|
135
121
|
* @returns {undefined}
|
|
136
122
|
*/
|
|
137
|
-
|
|
138
123
|
function unbind() {
|
|
139
124
|
try {
|
|
140
125
|
emitter.off('error', r);
|
|
141
|
-
} catch (err) {
|
|
126
|
+
} catch (err) {
|
|
127
|
+
// ignore
|
|
142
128
|
}
|
|
143
129
|
}
|
|
144
130
|
},
|
|
145
131
|
inBrowser: inBrowser,
|
|
146
132
|
inNode: inNode,
|
|
147
|
-
|
|
148
133
|
/**
|
|
149
134
|
* Wrap the desired mochaMethod with `skipInBrowser` to prevent the
|
|
150
135
|
* corresponding test or group of tests from running in a web browser
|
|
@@ -159,10 +144,8 @@ module.exports = {
|
|
|
159
144
|
if (!mochaMethod.skip) {
|
|
160
145
|
return mochaMethod;
|
|
161
146
|
}
|
|
162
|
-
|
|
163
147
|
return inBrowser() ? mochaMethod.skip : mochaMethod;
|
|
164
148
|
},
|
|
165
|
-
|
|
166
149
|
/**
|
|
167
150
|
* Wrap the desired mochaMethod with `skipInNode` to prevent the
|
|
168
151
|
* corresponding test or group of tests from running in node.
|
|
@@ -177,10 +160,8 @@ module.exports = {
|
|
|
177
160
|
if (!mochaMethod.skip) {
|
|
178
161
|
return mochaMethod;
|
|
179
162
|
}
|
|
180
|
-
|
|
181
163
|
return inNode() ? mochaMethod.skip : mochaMethod;
|
|
182
164
|
},
|
|
183
|
-
|
|
184
165
|
/**
|
|
185
166
|
* Wrap the desired mochaMethod with `skipInFirefox` to prevent the
|
|
186
167
|
* corresponding test or group of tests from running in Firefox.
|
|
@@ -195,10 +176,8 @@ module.exports = {
|
|
|
195
176
|
if (!mochaMethod.skip) {
|
|
196
177
|
return mochaMethod;
|
|
197
178
|
}
|
|
198
|
-
|
|
199
179
|
return inFirefox() ? mochaMethod.skip : mochaMethod;
|
|
200
180
|
},
|
|
201
|
-
|
|
202
181
|
/**
|
|
203
182
|
* Wrap the desired mochaMethod with `skipInSafari` to prevent the
|
|
204
183
|
* corresponding test or group of tests from running in Safari.
|
|
@@ -213,10 +192,8 @@ module.exports = {
|
|
|
213
192
|
if (!mochaMethod.skip) {
|
|
214
193
|
return mochaMethod;
|
|
215
194
|
}
|
|
216
|
-
|
|
217
195
|
return inSafari() ? mochaMethod.skip : mochaMethod;
|
|
218
196
|
},
|
|
219
|
-
|
|
220
197
|
/**
|
|
221
198
|
* Similar to skipInNode in that it prevents the test from running, but goes a
|
|
222
199
|
* step further to hide it from the list of skipped tests. Should be used when
|
|
@@ -227,7 +204,6 @@ module.exports = {
|
|
|
227
204
|
browserOnly: function browserOnly(mochaMethod) {
|
|
228
205
|
return inBrowser() ? mochaMethod : noop;
|
|
229
206
|
},
|
|
230
|
-
|
|
231
207
|
/**
|
|
232
208
|
* Similar to skipInBrowser in that it prevents the test from running, but
|
|
233
209
|
* goes a step further to hide it from the list of skipped tests. Should be
|
|
@@ -238,7 +214,6 @@ module.exports = {
|
|
|
238
214
|
nodeOnly: function nodeOnly(mochaMethod) {
|
|
239
215
|
return inNode() ? mochaMethod : noop;
|
|
240
216
|
},
|
|
241
|
-
|
|
242
217
|
/**
|
|
243
218
|
* Similar to skipInBrowser in that it prevents the test from running, but
|
|
244
219
|
* goes a step further to hide it from the list of skipped tests. Should be
|
|
@@ -249,7 +224,6 @@ module.exports = {
|
|
|
249
224
|
jenkinsOnly: function jenkinsOnly(mochaMethod) {
|
|
250
225
|
return inJenkins() ? mochaMethod : noop;
|
|
251
226
|
},
|
|
252
|
-
|
|
253
227
|
/**
|
|
254
228
|
* @param {number} max
|
|
255
229
|
* @param {string} event
|
|
@@ -260,20 +234,20 @@ module.exports = {
|
|
|
260
234
|
*/
|
|
261
235
|
expectActivity: function expectActivity(max, event, emitter, activityChecker, msg) {
|
|
262
236
|
var timer;
|
|
237
|
+
|
|
263
238
|
/**
|
|
264
239
|
* helper
|
|
265
240
|
* @private
|
|
266
241
|
* @returns {undefined}
|
|
267
242
|
*/
|
|
268
|
-
|
|
269
243
|
function unbind() {
|
|
270
244
|
try {
|
|
271
245
|
clearTimeout(timer);
|
|
272
246
|
emitter.off(event);
|
|
273
|
-
} catch (err) {
|
|
247
|
+
} catch (err) {
|
|
248
|
+
// ignore
|
|
274
249
|
}
|
|
275
250
|
}
|
|
276
|
-
|
|
277
251
|
return _promise.default.race([new _promise.default(function (resolve, reject) {
|
|
278
252
|
timer = setTimeout(function () {
|
|
279
253
|
reject(new Error("".concat(event, " did not fire within ").concat(max, "ms").concat(msg ? ": ".concat(msg) : '')));
|
|
@@ -281,7 +255,6 @@ module.exports = {
|
|
|
281
255
|
}), new _promise.default(function (resolve) {
|
|
282
256
|
emitter.on(event, function (result) {
|
|
283
257
|
var activity = result.data.activity;
|
|
284
|
-
|
|
285
258
|
if (activityChecker(activity)) {
|
|
286
259
|
unbind();
|
|
287
260
|
resolve(activity);
|
|
@@ -292,7 +265,6 @@ module.exports = {
|
|
|
292
265
|
throw reason;
|
|
293
266
|
});
|
|
294
267
|
},
|
|
295
|
-
|
|
296
268
|
/**
|
|
297
269
|
* Returns a promise that resolves after timeout or rejects
|
|
298
270
|
* when count has been exceeded. Will also reject if count
|
|
@@ -304,7 +276,8 @@ module.exports = {
|
|
|
304
276
|
* @returns {Promise}
|
|
305
277
|
*/
|
|
306
278
|
expectExactlyNEvents: function expectExactlyNEvents(max, count, event, emitter) {
|
|
307
|
-
var lastResult
|
|
279
|
+
var lastResult;
|
|
280
|
+
var timer;
|
|
308
281
|
var currentCount = 0;
|
|
309
282
|
return _promise.default.race([new _promise.default(function (resolve, reject) {
|
|
310
283
|
timer = setTimeout(function () {
|
|
@@ -316,17 +289,16 @@ module.exports = {
|
|
|
316
289
|
}, max);
|
|
317
290
|
}), new _promise.default(function (resolve, reject) {
|
|
318
291
|
emitter.on(event, fn);
|
|
292
|
+
|
|
319
293
|
/**
|
|
320
294
|
* helper
|
|
321
295
|
* @private
|
|
322
296
|
* @param {object} result
|
|
323
297
|
* @returns {undefined}
|
|
324
298
|
*/
|
|
325
|
-
|
|
326
299
|
function fn(result) {
|
|
327
300
|
lastResult = result;
|
|
328
301
|
currentCount += 1;
|
|
329
|
-
|
|
330
302
|
if (currentCount > count) {
|
|
331
303
|
emitter.off(event, fn);
|
|
332
304
|
clearTimeout(timer);
|
|
@@ -335,7 +307,6 @@ module.exports = {
|
|
|
335
307
|
}
|
|
336
308
|
})]);
|
|
337
309
|
},
|
|
338
|
-
|
|
339
310
|
/**
|
|
340
311
|
* Returns a promise that resolves when event is fired count times or rejects
|
|
341
312
|
* when max expires
|
|
@@ -354,15 +325,14 @@ module.exports = {
|
|
|
354
325
|
}, max);
|
|
355
326
|
}), new _promise.default(function (resolve) {
|
|
356
327
|
emitter.on(event, fn);
|
|
328
|
+
|
|
357
329
|
/**
|
|
358
330
|
* helper
|
|
359
331
|
* @private
|
|
360
332
|
* @returns {undefined}
|
|
361
333
|
*/
|
|
362
|
-
|
|
363
334
|
function fn() {
|
|
364
335
|
currentCount += 1;
|
|
365
|
-
|
|
366
336
|
if (currentCount === count) {
|
|
367
337
|
emitter.off(event, fn);
|
|
368
338
|
clearTimeout(timer);
|
|
@@ -371,7 +341,6 @@ module.exports = {
|
|
|
371
341
|
}
|
|
372
342
|
})]);
|
|
373
343
|
},
|
|
374
|
-
|
|
375
344
|
/**
|
|
376
345
|
* @param {number} max
|
|
377
346
|
* @param {string} event
|
|
@@ -392,7 +361,6 @@ module.exports = {
|
|
|
392
361
|
});
|
|
393
362
|
})]);
|
|
394
363
|
},
|
|
395
|
-
|
|
396
364
|
/**
|
|
397
365
|
* Only run the specified test in firefox
|
|
398
366
|
* @param {Function} mochaMethod
|
|
@@ -401,7 +369,6 @@ module.exports = {
|
|
|
401
369
|
firefoxOnly: function firefoxOnly(mochaMethod) {
|
|
402
370
|
return inFirefox() ? mochaMethod : noop;
|
|
403
371
|
},
|
|
404
|
-
|
|
405
372
|
/**
|
|
406
373
|
* Waits max ms or until emitter fires event, then resolves
|
|
407
374
|
* @param {number} max
|
|
@@ -416,7 +383,6 @@ module.exports = {
|
|
|
416
383
|
emitter.once(event, resolve);
|
|
417
384
|
})]);
|
|
418
385
|
},
|
|
419
|
-
|
|
420
386
|
/**
|
|
421
387
|
* Waits timeout ms or until the promise resolves. Rejects if the timeout is
|
|
422
388
|
* hit, otherwise resolves
|
|
@@ -431,7 +397,6 @@ module.exports = {
|
|
|
431
397
|
}, timeout);
|
|
432
398
|
})]);
|
|
433
399
|
},
|
|
434
|
-
|
|
435
400
|
/**
|
|
436
401
|
* Do not execute the specified mochaMethod until we pass the specified date
|
|
437
402
|
* @param {Date|string} until
|
|
@@ -441,23 +406,18 @@ module.exports = {
|
|
|
441
406
|
*/
|
|
442
407
|
snoozeUntil: function snoozeUntil(until, explanation) {
|
|
443
408
|
var now = new Date();
|
|
444
|
-
|
|
445
409
|
if (!explanation) {
|
|
446
410
|
throw new Error('You must defend your decision to snooze this test');
|
|
447
411
|
}
|
|
448
|
-
|
|
449
412
|
var d = new Date(until);
|
|
450
|
-
|
|
451
413
|
if ((0, _isNan.default)(d.getTime())) {
|
|
452
414
|
throw new Error("\"".concat(until, "\" does not appear to a valid date"));
|
|
453
415
|
}
|
|
454
|
-
|
|
455
416
|
var skip = now < d;
|
|
456
417
|
return function (mochaMethod) {
|
|
457
418
|
if (skip) {
|
|
458
419
|
return mochaMethod.skip;
|
|
459
420
|
}
|
|
460
|
-
|
|
461
421
|
return mochaMethod;
|
|
462
422
|
};
|
|
463
423
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["bowser","require","inNode","window","inBrowser","inSpecificBrowser","name","getParser","navigator","userAgent","isBrowser","inFirefox","inSafari","inJenkins","process","env","JENKINS","noop","module","exports","flaky","mochaMethod","envVar","skip","shouldSkip","handleErrorEvent","emitter","fn","r","p","resolve","reject","once","handler","race","then","unbind","catch","reason","add","e","off","err","skipInBrowser","skipInNode","skipInFirefox","skipInSafari","browserOnly","nodeOnly","jenkinsOnly","expectActivity","max","event","activityChecker","msg","timer","clearTimeout","setTimeout","Error","on","result","activity","data","expectExactlyNEvents","count","lastResult","currentCount","expectNEvents","expectEvent","firefoxOnly","maxWaitForEvent","maxWaitForPromise","timeout","promise","snoozeUntil","until","explanation","now","Date","d","getTime"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n/* globals window */\nconst bowser = require('bowser');\n\n/**\n * Indicates if we're running in node\n * @returns {boolean}\n * @private\n */\nfunction inNode() {\n return typeof window === 'undefined';\n}\n\n/**\n * Indicates if we're running in a web browser\n * @returns {boolean}\n * @private\n */\nfunction inBrowser() {\n return !inNode();\n}\n\n/**\n * Indicates if we are running in the named browser\n * @param {string} name name of the browser\n * @returns {boolean}\n */\nfunction inSpecificBrowser(name) {\n return window &&\n bowser.getParser(window.navigator.userAgent).isBrowser(name);\n}\n\n/**\n * Indicates if we're running in firefox\n * @returns {boolean}\n * @private\n */\nfunction inFirefox() {\n return inSpecificBrowser('firefox');\n}\n\n/**\n * Indicates if we're running in safari\n * @returns {boolean}\n * @private\n */\nfunction inSafari() {\n return inSpecificBrowser('safari');\n}\n\n/**\n * Indicates if we're running on Jenkins\n * @returns {boolean}\n * @private\n */\nfunction inJenkins() {\n return process.env.JENKINS;\n}\n\n/**\n * noop\n * @returns {undefined}\n * @private\n */\nfunction noop() {\n // intentionally empty\n}\n\nmodule.exports = {\n /**\n * Wrap the desired mochaMethod with `flaky` to indicate it's a flaky test\n * and exclude it from the test suite.\n * example:\n * `flaky(it)('sometimes passes and sometimes failes')`\n * @param {Function} mochaMethod `it` or `describe`\n * @param {string} envVar process.env.SKIP_FLAKY_TESTS\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n flaky: function flaky(mochaMethod, envVar) {\n // If mochaMethod doesn't have a skip method,\n // assume the mochaMethod is either a .skip or .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n const shouldSkip = envVar && envVar !== 'false' && !!envVar;\n\n return shouldSkip ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * A lot of failures get produced by EventEmitters, which makes them difficult to\n * detect in tests (they just look like timeouts). This is a test helper that\n * captures that error and turns it into a rejected promise\n * @param {EventEmitter} emitter\n * @param {Function} fn\n * @returns {Promise}\n */\n handleErrorEvent: function handleErrorEvent(emitter, fn) {\n let r;\n const p = new Promise((resolve, reject) => {\n r = reject;\n emitter.once('error', reject);\n });\n\n const handler = Promise.race([p, fn(emitter)])\n .then(unbind)\n .catch((reason) => {\n unbind();\n throw reason;\n });\n\n // Make it possible to add additional emitters\n handler.add = (e) => e.once('error', r);\n\n return handler;\n\n /**\n * unbinder\n * @private\n * @returns {undefined}\n */\n function unbind() {\n try {\n emitter.off('error', r);\n }\n catch (err) {\n // ignore\n }\n }\n },\n\n inBrowser,\n\n inNode,\n\n /**\n * Wrap the desired mochaMethod with `skipInBrowser` to prevent the\n * corresponding test or group of tests from running in a web browser\n * example:\n * `skipInBrowser(it)('does a thing that only works in node')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInBrowser: function skipInBrowser(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inBrowser() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInNode` to prevent the\n * corresponding test or group of tests from running in node.\n * example:\n * `skipInNode(it)('does a thing that only works in a web browser')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInNode: function skipInNode(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inNode() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInFirefox` to prevent the\n * corresponding test or group of tests from running in Firefox.\n * example:\n * `skipInFirefox(it)('does a thing that does not work in Firefox')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInFirefox: function skipInFirefox(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inFirefox() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInSafari` to prevent the\n * corresponding test or group of tests from running in Safari.\n * example:\n * `skipInSafari(it)('does a thing that does not work in Safari')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInSafari: function skipInSafari(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inSafari() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Similar to skipInNode in that it prevents the test from running, but goes a\n * step further to hide it from the list of skipped tests. Should be used when\n * the test will never be valid in NodeJS\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n browserOnly: function browserOnly(mochaMethod) {\n return inBrowser() ? mochaMethod : noop;\n },\n\n /**\n * Similar to skipInBrowser in that it prevents the test from running, but\n * goes a step further to hide it from the list of skipped tests. Should be\n * used when the test will never be valid in a Browser\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n nodeOnly: function nodeOnly(mochaMethod) {\n return inNode() ? mochaMethod : noop;\n },\n\n /**\n * Similar to skipInBrowser in that it prevents the test from running, but\n * goes a step further to hide it from the list of skipped tests. Should be\n * used when the test should be run on Jenkins only\n * @param {*} mochaMethod\n * @returns {Functions}\n */\n jenkinsOnly: function jenkinsOnly(mochaMethod) {\n return inJenkins() ? mochaMethod : noop;\n },\n\n /**\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @param {function} activityChecker // callback to check if activity matches\n * @param {string} msg\n * @returns {Promise<mixed>} Resolves with the activity\n */\n expectActivity: function expectActivity(max, event, emitter, activityChecker, msg) {\n let timer;\n\n /**\n * helper\n * @private\n * @returns {undefined}\n */\n function unbind() {\n try {\n clearTimeout(timer);\n emitter.off(event);\n }\n catch (err) {\n // ignore\n }\n }\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${event} did not fire within ${max}ms${msg ? `: ${msg}` : ''}`));\n }, max);\n }),\n new Promise((resolve) => {\n emitter.on(event, (result) => {\n const {data: {activity}} = result;\n\n if (activityChecker(activity)) {\n unbind();\n resolve(activity);\n }\n });\n })\n ])\n .catch((reason) => {\n unbind();\n throw reason;\n });\n },\n\n /**\n * Returns a promise that resolves after timeout or rejects\n * when count has been exceeded. Will also reject if count\n * hasn't been met after timeout\n * @param {number} max amount of time to wait for events in ms\n * @param {number} count number of events to expect in timeframe\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise}\n */\n expectExactlyNEvents: function expectExactlyNEvents(max, count, event, emitter) {\n let lastResult, timer;\n\n let currentCount = 0;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n if (currentCount === count) {\n resolve(lastResult);\n }\n else {\n reject(new Error(`${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`));\n }\n }, max);\n }),\n new Promise((resolve, reject) => {\n emitter.on(event, fn);\n\n /**\n * helper\n * @private\n * @param {object} result\n * @returns {undefined}\n */\n function fn(result) {\n lastResult = result;\n currentCount += 1;\n if (currentCount > count) {\n emitter.off(event, fn);\n clearTimeout(timer);\n reject(new Error(`${event} fired ${currentCount} times within ${max}ms. expected ${count} times`));\n }\n }\n })\n ]);\n },\n\n /**\n * Returns a promise that resolves when event is fired count times or rejects\n * when max expires\n * @param {number} max\n * @param {number} count\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise}\n */\n expectNEvents: function expectNEvents(max, count, event, emitter) {\n let timer;\n\n let currentCount = 0;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`));\n }, max);\n }),\n new Promise((resolve) => {\n emitter.on(event, fn);\n\n /**\n * helper\n * @private\n * @returns {undefined}\n */\n function fn() {\n currentCount += 1;\n if (currentCount === count) {\n emitter.off(event, fn);\n clearTimeout(timer);\n resolve();\n }\n }\n })\n ]);\n },\n\n /**\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @param {string} msg\n * @returns {Promise<mixed>} Resolves with the results of the event\n */\n expectEvent: function expectEvent(max, event, emitter, msg) {\n let timer;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${event} did not fire within ${max}ms${msg ? `: ${msg}` : ''}`));\n }, max);\n }),\n new Promise((resolve) => {\n emitter.once(event, (result) => {\n clearTimeout(timer);\n resolve(result);\n });\n })\n ]);\n },\n\n /**\n * Only run the specified test in firefox\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n firefoxOnly: function firefoxOnly(mochaMethod) {\n return inFirefox() ? mochaMethod : noop;\n },\n\n /**\n * Waits max ms or until emitter fires event, then resolves\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise<mixed>}\n */\n maxWaitForEvent: function maxWaitForEvent(max, event, emitter) {\n return Promise.race([\n new Promise((resolve) => {\n setTimeout(resolve, max);\n }),\n new Promise((resolve) => {\n emitter.once(event, resolve);\n })\n ]);\n },\n\n /**\n * Waits timeout ms or until the promise resolves. Rejects if the timeout is\n * hit, otherwise resolves\n * @param {number} timeout\n * @param {Promise} promise\n * @returns {Promise<mixed>}\n */\n maxWaitForPromise: function maxWaitForPromise(timeout, promise) {\n return Promise.race([\n promise,\n new Promise((resolve, reject) => {\n setTimeout(() => {\n reject(new Error(`Timeout of ${timeout} expired before promise completed`));\n }, timeout);\n })\n ]);\n },\n\n /**\n * Do not execute the specified mochaMethod until we pass the specified date\n * @param {Date|string} until\n * @param {string} explanation - Doesn't do anything, but forces you to defend\n * your decision to snooze a test\n * @returns {Function}\n */\n snoozeUntil: function snoozeUntil(until, explanation) {\n const now = new Date();\n\n if (!explanation) {\n throw new Error('You must defend your decision to snooze this test');\n }\n\n const d = new Date(until);\n\n if (Number.isNaN(d.getTime())) {\n throw new Error(`\"${until}\" does not appear to a valid date`);\n }\n\n const skip = now < d;\n\n return (mochaMethod) => {\n if (skip) {\n return mochaMethod.skip;\n }\n\n return mochaMethod;\n };\n }\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;;AACA;AACA,IAAMA,MAAM,GAAGC,OAAO,CAAC,QAAD,CAAtB;AAEA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,GAAkB;EAChB,OAAO,OAAOC,MAAP,KAAkB,WAAzB;AACD;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,GAAqB;EACnB,OAAO,CAACF,MAAM,EAAd;AACD;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASG,iBAAT,CAA2BC,IAA3B,EAAiC;EAC/B,OAAOH,MAAM,IACXH,MAAM,CAACO,SAAP,CAAiBJ,MAAM,CAACK,SAAP,CAAiBC,SAAlC,EAA6CC,SAA7C,CAAuDJ,IAAvD,CADF;AAED;AAED;AAC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ACEyC,iBAAiB,EAAE,SAASA,iBAAT,CAA2BC,OAA3B,EAAoCC,OAApC,EAA6C;IAC9D,OAAO,iBAAQvC,IAAR,CAAa,CAClBuC,OADkB,EAElB,qBAAY,UAAC3C,OAAD,EAAUC,MAAV,EAAqB;MAC/B0B,UAAU,CAAC,YAAM;QACf1B,MAAM,CAAC,IAAI2B,KAAJ,sBAAwBc,OAAxB,uCAAD,CAAN;MACD,CAFS,EAEPA,OAFO,CAAV;IAGD,CAJD,CAFkB,CAAb,CAAP;EAQD,CA1Xc;;EA4Xf;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAW,EAAE,SAASA,WAAT,CAAqBC,KAArB,EAA4BC,WAA5B,EAAyC;IACpD,IAAMC,GAAG,GAAG,IAAIC,IAAJ,EAAZ;;IAEA,IAAI,CAACF,WAAL,EAAkB;MAChB,MAAM,IAAIlB,KAAJ,CAAU,mDAAV,CAAN;IACD;;IAED,IAAMqB,CAAC,GAAG,IAAID,IAAJ,CAASH,KAAT,CAAV;;IAEA,IAAI,oBAAaI,CAAC,CAACC,OAAF,EAAb,CAAJ,EAA+B;MAC7B,MAAM,IAAItB,KAAJ,aAAciB,KAAd,wCAAN;IACD;;IAED,IAAMpD,IAAI,GAAGsD,GAAG,GAAGE,CAAnB;IAEA,OAAO,UAAC1D,WAAD,EAAiB;MACtB,IAAIE,IAAJ,EAAU;QACR,OAAOF,WAAW,CAACE,IAAnB;MACD;;MAED,OAAOF,WAAP;IACD,CAND;EAOD;AAzZc,CAAjB"}
|
|
1
|
+
{"version":3,"names":["bowser","require","inNode","window","inBrowser","inSpecificBrowser","name","getParser","navigator","userAgent","isBrowser","inFirefox","inSafari","inJenkins","process","env","JENKINS","noop","module","exports","flaky","mochaMethod","envVar","skip","shouldSkip","handleErrorEvent","emitter","fn","r","p","resolve","reject","once","handler","race","then","unbind","catch","reason","add","e","off","err","skipInBrowser","skipInNode","skipInFirefox","skipInSafari","browserOnly","nodeOnly","jenkinsOnly","expectActivity","max","event","activityChecker","msg","timer","clearTimeout","setTimeout","Error","on","result","activity","data","expectExactlyNEvents","count","lastResult","currentCount","expectNEvents","expectEvent","firefoxOnly","maxWaitForEvent","maxWaitForPromise","timeout","promise","snoozeUntil","until","explanation","now","Date","d","getTime"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nconst bowser = require('bowser');\n\n/**\n * Indicates if we're running in node\n * @returns {boolean}\n * @private\n */\nfunction inNode() {\n return typeof window === 'undefined';\n}\n\n/**\n * Indicates if we're running in a web browser\n * @returns {boolean}\n * @private\n */\nfunction inBrowser() {\n return !inNode();\n}\n\n/**\n * Indicates if we are running in the named browser\n * @param {string} name name of the browser\n * @returns {boolean}\n */\nfunction inSpecificBrowser(name) {\n return window && bowser.getParser(window.navigator.userAgent).isBrowser(name);\n}\n\n/**\n * Indicates if we're running in firefox\n * @returns {boolean}\n * @private\n */\nfunction inFirefox() {\n return inSpecificBrowser('firefox');\n}\n\n/**\n * Indicates if we're running in safari\n * @returns {boolean}\n * @private\n */\nfunction inSafari() {\n return inSpecificBrowser('safari');\n}\n\n/**\n * Indicates if we're running on Jenkins\n * @returns {boolean}\n * @private\n */\nfunction inJenkins() {\n return process.env.JENKINS;\n}\n\n/**\n * noop\n * @returns {undefined}\n * @private\n */\nfunction noop() {\n // intentionally empty\n}\n\nmodule.exports = {\n /**\n * Wrap the desired mochaMethod with `flaky` to indicate it's a flaky test\n * and exclude it from the test suite.\n * example:\n * `flaky(it)('sometimes passes and sometimes failes')`\n * @param {Function} mochaMethod `it` or `describe`\n * @param {string} envVar process.env.SKIP_FLAKY_TESTS\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n flaky: function flaky(mochaMethod, envVar) {\n // If mochaMethod doesn't have a skip method,\n // assume the mochaMethod is either a .skip or .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n const shouldSkip = envVar && envVar !== 'false' && !!envVar;\n\n return shouldSkip ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * A lot of failures get produced by EventEmitters, which makes them difficult to\n * detect in tests (they just look like timeouts). This is a test helper that\n * captures that error and turns it into a rejected promise\n * @param {EventEmitter} emitter\n * @param {Function} fn\n * @returns {Promise}\n */\n handleErrorEvent: function handleErrorEvent(emitter, fn) {\n let r;\n const p = new Promise((resolve, reject) => {\n r = reject;\n emitter.once('error', reject);\n });\n\n const handler = Promise.race([p, fn(emitter)])\n .then(unbind)\n .catch((reason) => {\n unbind();\n throw reason;\n });\n\n // Make it possible to add additional emitters\n handler.add = (e) => e.once('error', r);\n\n return handler;\n\n /**\n * unbinder\n * @private\n * @returns {undefined}\n */\n function unbind() {\n try {\n emitter.off('error', r);\n } catch (err) {\n // ignore\n }\n }\n },\n\n inBrowser,\n\n inNode,\n\n /**\n * Wrap the desired mochaMethod with `skipInBrowser` to prevent the\n * corresponding test or group of tests from running in a web browser\n * example:\n * `skipInBrowser(it)('does a thing that only works in node')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInBrowser: function skipInBrowser(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inBrowser() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInNode` to prevent the\n * corresponding test or group of tests from running in node.\n * example:\n * `skipInNode(it)('does a thing that only works in a web browser')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInNode: function skipInNode(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inNode() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInFirefox` to prevent the\n * corresponding test or group of tests from running in Firefox.\n * example:\n * `skipInFirefox(it)('does a thing that does not work in Firefox')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInFirefox: function skipInFirefox(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inFirefox() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Wrap the desired mochaMethod with `skipInSafari` to prevent the\n * corresponding test or group of tests from running in Safari.\n * example:\n * `skipInSafari(it)('does a thing that does not work in Safari')`\n * @param {Function} mochaMethod `it` or `describe`\n * @returns {Function} mochaMethod or mochaMethod.skip\n */\n skipInSafari: function skipInSafari(mochaMethod) {\n // If mochaMethod doesn't have a skip method, assume that mochaMethod is\n // already either a .skip or a .only\n if (!mochaMethod.skip) {\n return mochaMethod;\n }\n\n return inSafari() ? mochaMethod.skip : mochaMethod;\n },\n\n /**\n * Similar to skipInNode in that it prevents the test from running, but goes a\n * step further to hide it from the list of skipped tests. Should be used when\n * the test will never be valid in NodeJS\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n browserOnly: function browserOnly(mochaMethod) {\n return inBrowser() ? mochaMethod : noop;\n },\n\n /**\n * Similar to skipInBrowser in that it prevents the test from running, but\n * goes a step further to hide it from the list of skipped tests. Should be\n * used when the test will never be valid in a Browser\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n nodeOnly: function nodeOnly(mochaMethod) {\n return inNode() ? mochaMethod : noop;\n },\n\n /**\n * Similar to skipInBrowser in that it prevents the test from running, but\n * goes a step further to hide it from the list of skipped tests. Should be\n * used when the test should be run on Jenkins only\n * @param {*} mochaMethod\n * @returns {Functions}\n */\n jenkinsOnly: function jenkinsOnly(mochaMethod) {\n return inJenkins() ? mochaMethod : noop;\n },\n\n /**\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @param {function} activityChecker // callback to check if activity matches\n * @param {string} msg\n * @returns {Promise<mixed>} Resolves with the activity\n */\n expectActivity: function expectActivity(max, event, emitter, activityChecker, msg) {\n let timer;\n\n /**\n * helper\n * @private\n * @returns {undefined}\n */\n function unbind() {\n try {\n clearTimeout(timer);\n emitter.off(event);\n } catch (err) {\n // ignore\n }\n }\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${event} did not fire within ${max}ms${msg ? `: ${msg}` : ''}`));\n }, max);\n }),\n new Promise((resolve) => {\n emitter.on(event, (result) => {\n const {\n data: {activity},\n } = result;\n\n if (activityChecker(activity)) {\n unbind();\n resolve(activity);\n }\n });\n }),\n ]).catch((reason) => {\n unbind();\n throw reason;\n });\n },\n\n /**\n * Returns a promise that resolves after timeout or rejects\n * when count has been exceeded. Will also reject if count\n * hasn't been met after timeout\n * @param {number} max amount of time to wait for events in ms\n * @param {number} count number of events to expect in timeframe\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise}\n */\n expectExactlyNEvents: function expectExactlyNEvents(max, count, event, emitter) {\n let lastResult;\n let timer;\n\n let currentCount = 0;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n if (currentCount === count) {\n resolve(lastResult);\n } else {\n reject(\n new Error(\n `${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`\n )\n );\n }\n }, max);\n }),\n new Promise((resolve, reject) => {\n emitter.on(event, fn);\n\n /**\n * helper\n * @private\n * @param {object} result\n * @returns {undefined}\n */\n function fn(result) {\n lastResult = result;\n currentCount += 1;\n if (currentCount > count) {\n emitter.off(event, fn);\n clearTimeout(timer);\n reject(\n new Error(\n `${event} fired ${currentCount} times within ${max}ms. expected ${count} times`\n )\n );\n }\n }\n }),\n ]);\n },\n\n /**\n * Returns a promise that resolves when event is fired count times or rejects\n * when max expires\n * @param {number} max\n * @param {number} count\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise}\n */\n expectNEvents: function expectNEvents(max, count, event, emitter) {\n let timer;\n\n let currentCount = 0;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(\n new Error(\n `${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`\n )\n );\n }, max);\n }),\n new Promise((resolve) => {\n emitter.on(event, fn);\n\n /**\n * helper\n * @private\n * @returns {undefined}\n */\n function fn() {\n currentCount += 1;\n if (currentCount === count) {\n emitter.off(event, fn);\n clearTimeout(timer);\n resolve();\n }\n }\n }),\n ]);\n },\n\n /**\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @param {string} msg\n * @returns {Promise<mixed>} Resolves with the results of the event\n */\n expectEvent: function expectEvent(max, event, emitter, msg) {\n let timer;\n\n return Promise.race([\n new Promise((resolve, reject) => {\n timer = setTimeout(() => {\n reject(new Error(`${event} did not fire within ${max}ms${msg ? `: ${msg}` : ''}`));\n }, max);\n }),\n new Promise((resolve) => {\n emitter.once(event, (result) => {\n clearTimeout(timer);\n resolve(result);\n });\n }),\n ]);\n },\n\n /**\n * Only run the specified test in firefox\n * @param {Function} mochaMethod\n * @returns {Function}\n */\n firefoxOnly: function firefoxOnly(mochaMethod) {\n return inFirefox() ? mochaMethod : noop;\n },\n\n /**\n * Waits max ms or until emitter fires event, then resolves\n * @param {number} max\n * @param {string} event\n * @param {EventEmitter} emitter\n * @returns {Promise<mixed>}\n */\n maxWaitForEvent: function maxWaitForEvent(max, event, emitter) {\n return Promise.race([\n new Promise((resolve) => {\n setTimeout(resolve, max);\n }),\n new Promise((resolve) => {\n emitter.once(event, resolve);\n }),\n ]);\n },\n\n /**\n * Waits timeout ms or until the promise resolves. Rejects if the timeout is\n * hit, otherwise resolves\n * @param {number} timeout\n * @param {Promise} promise\n * @returns {Promise<mixed>}\n */\n maxWaitForPromise: function maxWaitForPromise(timeout, promise) {\n return Promise.race([\n promise,\n new Promise((resolve, reject) => {\n setTimeout(() => {\n reject(new Error(`Timeout of ${timeout} expired before promise completed`));\n }, timeout);\n }),\n ]);\n },\n\n /**\n * Do not execute the specified mochaMethod until we pass the specified date\n * @param {Date|string} until\n * @param {string} explanation - Doesn't do anything, but forces you to defend\n * your decision to snooze a test\n * @returns {Function}\n */\n snoozeUntil: function snoozeUntil(until, explanation) {\n const now = new Date();\n\n if (!explanation) {\n throw new Error('You must defend your decision to snooze this test');\n }\n\n const d = new Date(until);\n\n if (Number.isNaN(d.getTime())) {\n throw new Error(`\"${until}\" does not appear to a valid date`);\n }\n\n const skip = now < d;\n\n return (mochaMethod) => {\n if (skip) {\n return mochaMethod.skip;\n }\n\n return mochaMethod;\n };\n },\n};\n"],"mappings":";;;;;AAAA;AACA;AACA;;AAEA,IAAMA,MAAM,GAAGC,OAAO,CAAC,QAAQ,CAAC;;AAEhC;AACA;AACA;AACA;AACA;AACA,SAASC,MAAM,GAAG;EAChB,OAAO,OAAOC,MAAM,KAAK,WAAW;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,SAAS,GAAG;EACnB,OAAO,CAACF,MAAM,EAAE;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASG,iBAAiB,CAACC,IAAI,EAAE;EAC/B,OAAOH,MAAM,IAAIH,MAAM,CAACO,SAAS,CAACJ,MAAM,CAACK,SAAS,CAACC,SAAS,CAAC,CAACC,SAAS,CAACJ,IAAI,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASK,SAAS,GAAG;EACnB,OAAON,iBAAiB,CAAC,SAAS,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASO,QAAQ,GAAG;EAClB,OAAOP,iBAAiB,CAAC,QAAQ,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASQ,SAAS,GAAG;EACnB,OAAOC,OAAO,CAACC,GAAG,CAACC,OAAO;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,IAAI,GAAG;EACd;AAAA;AAGFC,MAAM,CAACC,OAAO,GAAG;EACf;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,KAAK,E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AAaI,CAAC,CAACC,OAAO,EAAE,CAAC,EAAE;MAC7B,MAAM,IAAItB,KAAK,aAAKiB,KAAK,wCAAoC;IAC/D;IAEA,IAAMpD,IAAI,GAAGsD,GAAG,GAAGE,CAAC;IAEpB,OAAO,UAAC1D,WAAW,EAAK;MACtB,IAAIE,IAAI,EAAE;QACR,OAAOF,WAAW,CAACE,IAAI;MACzB;MAEA,OAAOF,WAAW;IACpB,CAAC;EACH;AACF,CAAC"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
const bowser = require('bowser');
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -28,8 +28,7 @@ function inBrowser() {
|
|
|
28
28
|
* @returns {boolean}
|
|
29
29
|
*/
|
|
30
30
|
function inSpecificBrowser(name) {
|
|
31
|
-
return window &&
|
|
32
|
-
bowser.getParser(window.navigator.userAgent).isBrowser(name);
|
|
31
|
+
return window && bowser.getParser(window.navigator.userAgent).isBrowser(name);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -125,8 +124,7 @@ module.exports = {
|
|
|
125
124
|
function unbind() {
|
|
126
125
|
try {
|
|
127
126
|
emitter.off('error', r);
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
127
|
+
} catch (err) {
|
|
130
128
|
// ignore
|
|
131
129
|
}
|
|
132
130
|
}
|
|
@@ -261,8 +259,7 @@ module.exports = {
|
|
|
261
259
|
try {
|
|
262
260
|
clearTimeout(timer);
|
|
263
261
|
emitter.off(event);
|
|
264
|
-
}
|
|
265
|
-
catch (err) {
|
|
262
|
+
} catch (err) {
|
|
266
263
|
// ignore
|
|
267
264
|
}
|
|
268
265
|
}
|
|
@@ -275,19 +272,20 @@ module.exports = {
|
|
|
275
272
|
}),
|
|
276
273
|
new Promise((resolve) => {
|
|
277
274
|
emitter.on(event, (result) => {
|
|
278
|
-
const {
|
|
275
|
+
const {
|
|
276
|
+
data: {activity},
|
|
277
|
+
} = result;
|
|
279
278
|
|
|
280
279
|
if (activityChecker(activity)) {
|
|
281
280
|
unbind();
|
|
282
281
|
resolve(activity);
|
|
283
282
|
}
|
|
284
283
|
});
|
|
285
|
-
})
|
|
286
|
-
])
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
});
|
|
284
|
+
}),
|
|
285
|
+
]).catch((reason) => {
|
|
286
|
+
unbind();
|
|
287
|
+
throw reason;
|
|
288
|
+
});
|
|
291
289
|
},
|
|
292
290
|
|
|
293
291
|
/**
|
|
@@ -301,7 +299,8 @@ module.exports = {
|
|
|
301
299
|
* @returns {Promise}
|
|
302
300
|
*/
|
|
303
301
|
expectExactlyNEvents: function expectExactlyNEvents(max, count, event, emitter) {
|
|
304
|
-
let lastResult
|
|
302
|
+
let lastResult;
|
|
303
|
+
let timer;
|
|
305
304
|
|
|
306
305
|
let currentCount = 0;
|
|
307
306
|
|
|
@@ -310,9 +309,12 @@ module.exports = {
|
|
|
310
309
|
timer = setTimeout(() => {
|
|
311
310
|
if (currentCount === count) {
|
|
312
311
|
resolve(lastResult);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
312
|
+
} else {
|
|
313
|
+
reject(
|
|
314
|
+
new Error(
|
|
315
|
+
`${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`
|
|
316
|
+
)
|
|
317
|
+
);
|
|
316
318
|
}
|
|
317
319
|
}, max);
|
|
318
320
|
}),
|
|
@@ -331,10 +333,14 @@ module.exports = {
|
|
|
331
333
|
if (currentCount > count) {
|
|
332
334
|
emitter.off(event, fn);
|
|
333
335
|
clearTimeout(timer);
|
|
334
|
-
reject(
|
|
336
|
+
reject(
|
|
337
|
+
new Error(
|
|
338
|
+
`${event} fired ${currentCount} times within ${max}ms. expected ${count} times`
|
|
339
|
+
)
|
|
340
|
+
);
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
|
-
})
|
|
343
|
+
}),
|
|
338
344
|
]);
|
|
339
345
|
},
|
|
340
346
|
|
|
@@ -355,7 +361,11 @@ module.exports = {
|
|
|
355
361
|
return Promise.race([
|
|
356
362
|
new Promise((resolve, reject) => {
|
|
357
363
|
timer = setTimeout(() => {
|
|
358
|
-
reject(
|
|
364
|
+
reject(
|
|
365
|
+
new Error(
|
|
366
|
+
`${event} fired only ${currentCount} times within ${max}ms. expected ${count} times`
|
|
367
|
+
)
|
|
368
|
+
);
|
|
359
369
|
}, max);
|
|
360
370
|
}),
|
|
361
371
|
new Promise((resolve) => {
|
|
@@ -374,7 +384,7 @@ module.exports = {
|
|
|
374
384
|
resolve();
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
|
-
})
|
|
387
|
+
}),
|
|
378
388
|
]);
|
|
379
389
|
},
|
|
380
390
|
|
|
@@ -399,7 +409,7 @@ module.exports = {
|
|
|
399
409
|
clearTimeout(timer);
|
|
400
410
|
resolve(result);
|
|
401
411
|
});
|
|
402
|
-
})
|
|
412
|
+
}),
|
|
403
413
|
]);
|
|
404
414
|
},
|
|
405
415
|
|
|
@@ -426,7 +436,7 @@ module.exports = {
|
|
|
426
436
|
}),
|
|
427
437
|
new Promise((resolve) => {
|
|
428
438
|
emitter.once(event, resolve);
|
|
429
|
-
})
|
|
439
|
+
}),
|
|
430
440
|
]);
|
|
431
441
|
},
|
|
432
442
|
|
|
@@ -444,7 +454,7 @@ module.exports = {
|
|
|
444
454
|
setTimeout(() => {
|
|
445
455
|
reject(new Error(`Timeout of ${timeout} expired before promise completed`));
|
|
446
456
|
}, timeout);
|
|
447
|
-
})
|
|
457
|
+
}),
|
|
448
458
|
]);
|
|
449
459
|
},
|
|
450
460
|
|
|
@@ -477,5 +487,5 @@ module.exports = {
|
|
|
477
487
|
|
|
478
488
|
return mochaMethod;
|
|
479
489
|
};
|
|
480
|
-
}
|
|
490
|
+
},
|
|
481
491
|
};
|