@webex/test-helper-mocha 2.59.2 → 2.59.3-next.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/.eslintrc.js CHANGED
@@ -1,6 +1,6 @@
1
- const config = {
2
- root: true,
3
- extends: ['@webex/eslint-config-legacy'],
4
- };
5
-
6
- module.exports = config;
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
package/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # @webex/test-helper-mocha
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- >
6
-
7
- - [Install](#install)
8
- - [Usage](#usage)
9
- - [Contribute](#contribute)
10
- - [Maintainers](#maintainers)
11
- - [License](#license)
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install --save @webex/test-helper-mocha
17
- ```
18
-
19
- ## Usage
20
-
21
- ## Maintainers
22
-
23
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
24
-
25
- ## Contribute
26
-
27
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
28
-
29
- ## License
30
-
31
- © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/test-helper-mocha
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ >
6
+
7
+ - [Install](#install)
8
+ - [Usage](#usage)
9
+ - [Contribute](#contribute)
10
+ - [Maintainers](#maintainers)
11
+ - [License](#license)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install --save @webex/test-helper-mocha
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ## Maintainers
22
+
23
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
24
+
25
+ ## Contribute
26
+
27
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
28
+
29
+ ## License
30
+
31
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const babelConfigLegacy = require('@webex/babel-config-legacy');
2
-
3
- module.exports = babelConfigLegacy;
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
package/dist/index.js CHANGED
@@ -3,83 +3,83 @@
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
4
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
5
5
  var _isNan = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/number/is-nan"));
6
- /*!
7
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
6
+ /*!
7
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
8
8
  */
9
9
 
10
10
  var bowser = require('bowser');
11
11
 
12
- /**
13
- * Indicates if we're running in node
14
- * @returns {boolean}
15
- * @private
12
+ /**
13
+ * Indicates if we're running in node
14
+ * @returns {boolean}
15
+ * @private
16
16
  */
17
17
  function inNode() {
18
18
  return typeof window === 'undefined';
19
19
  }
20
20
 
21
- /**
22
- * Indicates if we're running in a web browser
23
- * @returns {boolean}
24
- * @private
21
+ /**
22
+ * Indicates if we're running in a web browser
23
+ * @returns {boolean}
24
+ * @private
25
25
  */
26
26
  function inBrowser() {
27
27
  return !inNode();
28
28
  }
29
29
 
30
- /**
31
- * Indicates if we are running in the named browser
32
- * @param {string} name name of the browser
33
- * @returns {boolean}
30
+ /**
31
+ * Indicates if we are running in the named browser
32
+ * @param {string} name name of the browser
33
+ * @returns {boolean}
34
34
  */
35
35
  function inSpecificBrowser(name) {
36
36
  return window && bowser.getParser(window.navigator.userAgent).isBrowser(name);
37
37
  }
38
38
 
39
- /**
40
- * Indicates if we're running in firefox
41
- * @returns {boolean}
42
- * @private
39
+ /**
40
+ * Indicates if we're running in firefox
41
+ * @returns {boolean}
42
+ * @private
43
43
  */
44
44
  function inFirefox() {
45
45
  return inSpecificBrowser('firefox');
46
46
  }
47
47
 
48
- /**
49
- * Indicates if we're running in safari
50
- * @returns {boolean}
51
- * @private
48
+ /**
49
+ * Indicates if we're running in safari
50
+ * @returns {boolean}
51
+ * @private
52
52
  */
53
53
  function inSafari() {
54
54
  return inSpecificBrowser('safari');
55
55
  }
56
56
 
57
- /**
58
- * Indicates if we're running on Jenkins
59
- * @returns {boolean}
60
- * @private
57
+ /**
58
+ * Indicates if we're running on Jenkins
59
+ * @returns {boolean}
60
+ * @private
61
61
  */
62
62
  function inJenkins() {
63
63
  return process.env.JENKINS;
64
64
  }
65
65
 
66
- /**
67
- * noop
68
- * @returns {undefined}
69
- * @private
66
+ /**
67
+ * noop
68
+ * @returns {undefined}
69
+ * @private
70
70
  */
71
71
  function noop() {
72
72
  // intentionally empty
73
73
  }
74
74
  module.exports = {
75
- /**
76
- * Wrap the desired mochaMethod with `flaky` to indicate it's a flaky test
77
- * and exclude it from the test suite.
78
- * example:
79
- * `flaky(it)('sometimes passes and sometimes failes')`
80
- * @param {Function} mochaMethod `it` or `describe`
81
- * @param {string} envVar process.env.SKIP_FLAKY_TESTS
82
- * @returns {Function} mochaMethod or mochaMethod.skip
75
+ /**
76
+ * Wrap the desired mochaMethod with `flaky` to indicate it's a flaky test
77
+ * and exclude it from the test suite.
78
+ * example:
79
+ * `flaky(it)('sometimes passes and sometimes failes')`
80
+ * @param {Function} mochaMethod `it` or `describe`
81
+ * @param {string} envVar process.env.SKIP_FLAKY_TESTS
82
+ * @returns {Function} mochaMethod or mochaMethod.skip
83
83
  */
84
84
  flaky: function flaky(mochaMethod, envVar) {
85
85
  // If mochaMethod doesn't have a skip method,
@@ -90,13 +90,13 @@ module.exports = {
90
90
  var shouldSkip = envVar && envVar !== 'false' && !!envVar;
91
91
  return shouldSkip ? mochaMethod.skip : mochaMethod;
92
92
  },
93
- /**
94
- * A lot of failures get produced by EventEmitters, which makes them difficult to
95
- * detect in tests (they just look like timeouts). This is a test helper that
96
- * captures that error and turns it into a rejected promise
97
- * @param {EventEmitter} emitter
98
- * @param {Function} fn
99
- * @returns {Promise}
93
+ /**
94
+ * A lot of failures get produced by EventEmitters, which makes them difficult to
95
+ * detect in tests (they just look like timeouts). This is a test helper that
96
+ * captures that error and turns it into a rejected promise
97
+ * @param {EventEmitter} emitter
98
+ * @param {Function} fn
99
+ * @returns {Promise}
100
100
  */
101
101
  handleErrorEvent: function handleErrorEvent(emitter, fn) {
102
102
  var r;
@@ -115,10 +115,10 @@ module.exports = {
115
115
  };
116
116
  return handler;
117
117
 
118
- /**
119
- * unbinder
120
- * @private
121
- * @returns {undefined}
118
+ /**
119
+ * unbinder
120
+ * @private
121
+ * @returns {undefined}
122
122
  */
123
123
  function unbind() {
124
124
  try {
@@ -130,13 +130,13 @@ module.exports = {
130
130
  },
131
131
  inBrowser: inBrowser,
132
132
  inNode: inNode,
133
- /**
134
- * Wrap the desired mochaMethod with `skipInBrowser` to prevent the
135
- * corresponding test or group of tests from running in a web browser
136
- * example:
137
- * `skipInBrowser(it)('does a thing that only works in node')`
138
- * @param {Function} mochaMethod `it` or `describe`
139
- * @returns {Function} mochaMethod or mochaMethod.skip
133
+ /**
134
+ * Wrap the desired mochaMethod with `skipInBrowser` to prevent the
135
+ * corresponding test or group of tests from running in a web browser
136
+ * example:
137
+ * `skipInBrowser(it)('does a thing that only works in node')`
138
+ * @param {Function} mochaMethod `it` or `describe`
139
+ * @returns {Function} mochaMethod or mochaMethod.skip
140
140
  */
141
141
  skipInBrowser: function skipInBrowser(mochaMethod) {
142
142
  // If mochaMethod doesn't have a skip method, assume that mochaMethod is
@@ -146,13 +146,13 @@ module.exports = {
146
146
  }
147
147
  return inBrowser() ? mochaMethod.skip : mochaMethod;
148
148
  },
149
- /**
150
- * Wrap the desired mochaMethod with `skipInNode` to prevent the
151
- * corresponding test or group of tests from running in node.
152
- * example:
153
- * `skipInNode(it)('does a thing that only works in a web browser')`
154
- * @param {Function} mochaMethod `it` or `describe`
155
- * @returns {Function} mochaMethod or mochaMethod.skip
149
+ /**
150
+ * Wrap the desired mochaMethod with `skipInNode` to prevent the
151
+ * corresponding test or group of tests from running in node.
152
+ * example:
153
+ * `skipInNode(it)('does a thing that only works in a web browser')`
154
+ * @param {Function} mochaMethod `it` or `describe`
155
+ * @returns {Function} mochaMethod or mochaMethod.skip
156
156
  */
157
157
  skipInNode: function skipInNode(mochaMethod) {
158
158
  // If mochaMethod doesn't have a skip method, assume that mochaMethod is
@@ -162,13 +162,13 @@ module.exports = {
162
162
  }
163
163
  return inNode() ? mochaMethod.skip : mochaMethod;
164
164
  },
165
- /**
166
- * Wrap the desired mochaMethod with `skipInFirefox` to prevent the
167
- * corresponding test or group of tests from running in Firefox.
168
- * example:
169
- * `skipInFirefox(it)('does a thing that does not work in Firefox')`
170
- * @param {Function} mochaMethod `it` or `describe`
171
- * @returns {Function} mochaMethod or mochaMethod.skip
165
+ /**
166
+ * Wrap the desired mochaMethod with `skipInFirefox` to prevent the
167
+ * corresponding test or group of tests from running in Firefox.
168
+ * example:
169
+ * `skipInFirefox(it)('does a thing that does not work in Firefox')`
170
+ * @param {Function} mochaMethod `it` or `describe`
171
+ * @returns {Function} mochaMethod or mochaMethod.skip
172
172
  */
173
173
  skipInFirefox: function skipInFirefox(mochaMethod) {
174
174
  // If mochaMethod doesn't have a skip method, assume that mochaMethod is
@@ -178,13 +178,13 @@ module.exports = {
178
178
  }
179
179
  return inFirefox() ? mochaMethod.skip : mochaMethod;
180
180
  },
181
- /**
182
- * Wrap the desired mochaMethod with `skipInSafari` to prevent the
183
- * corresponding test or group of tests from running in Safari.
184
- * example:
185
- * `skipInSafari(it)('does a thing that does not work in Safari')`
186
- * @param {Function} mochaMethod `it` or `describe`
187
- * @returns {Function} mochaMethod or mochaMethod.skip
181
+ /**
182
+ * Wrap the desired mochaMethod with `skipInSafari` to prevent the
183
+ * corresponding test or group of tests from running in Safari.
184
+ * example:
185
+ * `skipInSafari(it)('does a thing that does not work in Safari')`
186
+ * @param {Function} mochaMethod `it` or `describe`
187
+ * @returns {Function} mochaMethod or mochaMethod.skip
188
188
  */
189
189
  skipInSafari: function skipInSafari(mochaMethod) {
190
190
  // If mochaMethod doesn't have a skip method, assume that mochaMethod is
@@ -194,51 +194,51 @@ module.exports = {
194
194
  }
195
195
  return inSafari() ? mochaMethod.skip : mochaMethod;
196
196
  },
197
- /**
198
- * Similar to skipInNode in that it prevents the test from running, but goes a
199
- * step further to hide it from the list of skipped tests. Should be used when
200
- * the test will never be valid in NodeJS
201
- * @param {Function} mochaMethod
202
- * @returns {Function}
197
+ /**
198
+ * Similar to skipInNode in that it prevents the test from running, but goes a
199
+ * step further to hide it from the list of skipped tests. Should be used when
200
+ * the test will never be valid in NodeJS
201
+ * @param {Function} mochaMethod
202
+ * @returns {Function}
203
203
  */
204
204
  browserOnly: function browserOnly(mochaMethod) {
205
205
  return inBrowser() ? mochaMethod : noop;
206
206
  },
207
- /**
208
- * Similar to skipInBrowser in that it prevents the test from running, but
209
- * goes a step further to hide it from the list of skipped tests. Should be
210
- * used when the test will never be valid in a Browser
211
- * @param {Function} mochaMethod
212
- * @returns {Function}
207
+ /**
208
+ * Similar to skipInBrowser in that it prevents the test from running, but
209
+ * goes a step further to hide it from the list of skipped tests. Should be
210
+ * used when the test will never be valid in a Browser
211
+ * @param {Function} mochaMethod
212
+ * @returns {Function}
213
213
  */
214
214
  nodeOnly: function nodeOnly(mochaMethod) {
215
215
  return inNode() ? mochaMethod : noop;
216
216
  },
217
- /**
218
- * Similar to skipInBrowser in that it prevents the test from running, but
219
- * goes a step further to hide it from the list of skipped tests. Should be
220
- * used when the test should be run on Jenkins only
221
- * @param {*} mochaMethod
222
- * @returns {Functions}
217
+ /**
218
+ * Similar to skipInBrowser in that it prevents the test from running, but
219
+ * goes a step further to hide it from the list of skipped tests. Should be
220
+ * used when the test should be run on Jenkins only
221
+ * @param {*} mochaMethod
222
+ * @returns {Functions}
223
223
  */
224
224
  jenkinsOnly: function jenkinsOnly(mochaMethod) {
225
225
  return inJenkins() ? mochaMethod : noop;
226
226
  },
227
- /**
228
- * @param {number} max
229
- * @param {string} event
230
- * @param {EventEmitter} emitter
231
- * @param {function} activityChecker // callback to check if activity matches
232
- * @param {string} msg
233
- * @returns {Promise<mixed>} Resolves with the activity
227
+ /**
228
+ * @param {number} max
229
+ * @param {string} event
230
+ * @param {EventEmitter} emitter
231
+ * @param {function} activityChecker // callback to check if activity matches
232
+ * @param {string} msg
233
+ * @returns {Promise<mixed>} Resolves with the activity
234
234
  */
235
235
  expectActivity: function expectActivity(max, event, emitter, activityChecker, msg) {
236
236
  var timer;
237
237
 
238
- /**
239
- * helper
240
- * @private
241
- * @returns {undefined}
238
+ /**
239
+ * helper
240
+ * @private
241
+ * @returns {undefined}
242
242
  */
243
243
  function unbind() {
244
244
  try {
@@ -265,15 +265,15 @@ module.exports = {
265
265
  throw reason;
266
266
  });
267
267
  },
268
- /**
269
- * Returns a promise that resolves after timeout or rejects
270
- * when count has been exceeded. Will also reject if count
271
- * hasn't been met after timeout
272
- * @param {number} max amount of time to wait for events in ms
273
- * @param {number} count number of events to expect in timeframe
274
- * @param {string} event
275
- * @param {EventEmitter} emitter
276
- * @returns {Promise}
268
+ /**
269
+ * Returns a promise that resolves after timeout or rejects
270
+ * when count has been exceeded. Will also reject if count
271
+ * hasn't been met after timeout
272
+ * @param {number} max amount of time to wait for events in ms
273
+ * @param {number} count number of events to expect in timeframe
274
+ * @param {string} event
275
+ * @param {EventEmitter} emitter
276
+ * @returns {Promise}
277
277
  */
278
278
  expectExactlyNEvents: function expectExactlyNEvents(max, count, event, emitter) {
279
279
  var lastResult;
@@ -290,11 +290,11 @@ module.exports = {
290
290
  }), new _promise.default(function (resolve, reject) {
291
291
  emitter.on(event, fn);
292
292
 
293
- /**
294
- * helper
295
- * @private
296
- * @param {object} result
297
- * @returns {undefined}
293
+ /**
294
+ * helper
295
+ * @private
296
+ * @param {object} result
297
+ * @returns {undefined}
298
298
  */
299
299
  function fn(result) {
300
300
  lastResult = result;
@@ -307,14 +307,14 @@ module.exports = {
307
307
  }
308
308
  })]);
309
309
  },
310
- /**
311
- * Returns a promise that resolves when event is fired count times or rejects
312
- * when max expires
313
- * @param {number} max
314
- * @param {number} count
315
- * @param {string} event
316
- * @param {EventEmitter} emitter
317
- * @returns {Promise}
310
+ /**
311
+ * Returns a promise that resolves when event is fired count times or rejects
312
+ * when max expires
313
+ * @param {number} max
314
+ * @param {number} count
315
+ * @param {string} event
316
+ * @param {EventEmitter} emitter
317
+ * @returns {Promise}
318
318
  */
319
319
  expectNEvents: function expectNEvents(max, count, event, emitter) {
320
320
  var timer;
@@ -326,10 +326,10 @@ module.exports = {
326
326
  }), new _promise.default(function (resolve) {
327
327
  emitter.on(event, fn);
328
328
 
329
- /**
330
- * helper
331
- * @private
332
- * @returns {undefined}
329
+ /**
330
+ * helper
331
+ * @private
332
+ * @returns {undefined}
333
333
  */
334
334
  function fn() {
335
335
  currentCount += 1;
@@ -341,12 +341,12 @@ module.exports = {
341
341
  }
342
342
  })]);
343
343
  },
344
- /**
345
- * @param {number} max
346
- * @param {string} event
347
- * @param {EventEmitter} emitter
348
- * @param {string} msg
349
- * @returns {Promise<mixed>} Resolves with the results of the event
344
+ /**
345
+ * @param {number} max
346
+ * @param {string} event
347
+ * @param {EventEmitter} emitter
348
+ * @param {string} msg
349
+ * @returns {Promise<mixed>} Resolves with the results of the event
350
350
  */
351
351
  expectEvent: function expectEvent(max, event, emitter, msg) {
352
352
  var timer;
@@ -361,20 +361,20 @@ module.exports = {
361
361
  });
362
362
  })]);
363
363
  },
364
- /**
365
- * Only run the specified test in firefox
366
- * @param {Function} mochaMethod
367
- * @returns {Function}
364
+ /**
365
+ * Only run the specified test in firefox
366
+ * @param {Function} mochaMethod
367
+ * @returns {Function}
368
368
  */
369
369
  firefoxOnly: function firefoxOnly(mochaMethod) {
370
370
  return inFirefox() ? mochaMethod : noop;
371
371
  },
372
- /**
373
- * Waits max ms or until emitter fires event, then resolves
374
- * @param {number} max
375
- * @param {string} event
376
- * @param {EventEmitter} emitter
377
- * @returns {Promise<mixed>}
372
+ /**
373
+ * Waits max ms or until emitter fires event, then resolves
374
+ * @param {number} max
375
+ * @param {string} event
376
+ * @param {EventEmitter} emitter
377
+ * @returns {Promise<mixed>}
378
378
  */
379
379
  maxWaitForEvent: function maxWaitForEvent(max, event, emitter) {
380
380
  return _promise.default.race([new _promise.default(function (resolve) {
@@ -383,12 +383,12 @@ module.exports = {
383
383
  emitter.once(event, resolve);
384
384
  })]);
385
385
  },
386
- /**
387
- * Waits timeout ms or until the promise resolves. Rejects if the timeout is
388
- * hit, otherwise resolves
389
- * @param {number} timeout
390
- * @param {Promise} promise
391
- * @returns {Promise<mixed>}
386
+ /**
387
+ * Waits timeout ms or until the promise resolves. Rejects if the timeout is
388
+ * hit, otherwise resolves
389
+ * @param {number} timeout
390
+ * @param {Promise} promise
391
+ * @returns {Promise<mixed>}
392
392
  */
393
393
  maxWaitForPromise: function maxWaitForPromise(timeout, promise) {
394
394
  return _promise.default.race([promise, new _promise.default(function (resolve, reject) {
@@ -397,12 +397,12 @@ module.exports = {
397
397
  }, timeout);
398
398
  })]);
399
399
  },
400
- /**
401
- * Do not execute the specified mochaMethod until we pass the specified date
402
- * @param {Date|string} until
403
- * @param {string} explanation - Doesn't do anything, but forces you to defend
404
- * your decision to snooze a test
405
- * @returns {Function}
400
+ /**
401
+ * Do not execute the specified mochaMethod until we pass the specified date
402
+ * @param {Date|string} until
403
+ * @param {string} explanation - Doesn't do anything, but forces you to defend
404
+ * your decision to snooze a test
405
+ * @returns {Function}
406
406
  */
407
407
  snoozeUntil: function snoozeUntil(until, explanation) {
408
408
  var now = new Date();