mocha 8.1.1 → 8.1.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # 8.1.2 / 2020-08-25
2
+
3
+ ## :bug: Fixes
4
+
5
+ - [#4418](https://github.com/mochajs/mocha/issues/4418): Fix command-line flag incompatibility in forthcoming Node.js v14.9.0 ([**@boneskull**](https://github.com/boneskull))
6
+ - [#4401](https://github.com/mochajs/mocha/issues/4401): Fix missing global variable in browser ([**@irrationelle**](https://github.com/irrationelle))
7
+
8
+ ## :lock: Security Fixes
9
+
10
+ - [#4396](https://github.com/mochajs/mocha/issues/4396): Update many dependencies ([**@GChuf**](https://github.com/GChuf))
11
+
12
+ ## :book: Documentation
13
+
14
+ - Various fixes by [**@sujin-park**](https://github.com/sujin-park), [**@wwhurin**](https://github.com/wwhurin) & [**@Donghoon759**](https://github.com/Donghoon759)
15
+
1
16
  # 8.1.1 / 2020-08-04
2
17
 
3
18
  ## :bug: Fixes
package/browser-entry.js CHANGED
@@ -210,8 +210,8 @@ Mocha.process = process;
210
210
  * Expose mocha.
211
211
  */
212
212
 
213
- mocha.Mocha = Mocha;
214
- mocha.mocha = mocha;
213
+ global.Mocha = Mocha;
214
+ global.mocha = mocha;
215
215
 
216
216
  // this allows test/acceptance/required-tokens.js to pass; thus,
217
217
  // you can now do `const describe = require('mocha').describe` in a
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  const nodeFlags = process.allowedNodeEnvironmentFlags;
10
+ const {isMochaFlag} = require('./run-option-metadata');
10
11
  const unparse = require('yargs-unparser');
11
12
 
12
13
  /**
@@ -43,16 +44,14 @@ exports.isNodeFlag = (flag, bareword = true) => {
43
44
  flag = flag.replace(/^--?/, '');
44
45
  }
45
46
  return (
46
- // treat --require/-r as Mocha flag even though it's also a node flag
47
- !(flag === 'require' || flag === 'r') &&
48
47
  // check actual node flags from `process.allowedNodeEnvironmentFlags`,
49
48
  // then historical support for various V8 and non-`NODE_OPTIONS` flags
50
49
  // and also any V8 flags with `--v8-` prefix
51
- ((nodeFlags && nodeFlags.has(flag)) ||
52
- debugFlags.has(flag) ||
53
- /(?:preserve-symlinks(?:-main)?|harmony(?:[_-]|$)|(?:trace[_-].+$)|gc(?:[_-]global)?$|es[_-]staging$|use[_-]strict$|v8[_-](?!options).+?$)/.test(
54
- flag
55
- ))
50
+ (!isMochaFlag(flag) && nodeFlags && nodeFlags.has(flag)) ||
51
+ debugFlags.has(flag) ||
52
+ /(?:preserve-symlinks(?:-main)?|harmony(?:[_-]|$)|(?:trace[_-].+$)|gc(?:[_-]global)?$|es[_-]staging$|use[_-]strict$|v8[_-](?!options).+?$)/.test(
53
+ flag
54
+ )
56
55
  );
57
56
  };
58
57
 
@@ -12,7 +12,7 @@
12
12
  * @type {{string:string[]}}
13
13
  * @private
14
14
  */
15
- exports.types = {
15
+ const TYPES = (exports.types = {
16
16
  array: [
17
17
  'extension',
18
18
  'file',
@@ -58,7 +58,7 @@ exports.types = {
58
58
  'slow',
59
59
  'timeout'
60
60
  ]
61
- };
61
+ });
62
62
 
63
63
  /**
64
64
  * Option aliases keyed by canonical option name.
@@ -88,3 +88,26 @@ exports.aliases = {
88
88
  ui: ['u'],
89
89
  watch: ['w']
90
90
  };
91
+
92
+ const ALL_MOCHA_FLAGS = Object.keys(TYPES).reduce((acc, key) => {
93
+ // gets all flags from each of the fields in `types`, adds those,
94
+ // then adds aliases of each flag (if any)
95
+ TYPES[key].forEach(flag => {
96
+ acc.add(flag);
97
+ const aliases = exports.aliases[flag] || [];
98
+ aliases.forEach(alias => {
99
+ acc.add(alias);
100
+ });
101
+ });
102
+ return acc;
103
+ }, new Set());
104
+
105
+ /**
106
+ * Returns `true` if the provided `flag` is known to Mocha.
107
+ * @param {string} flag - Flag to check
108
+ * @returns {boolean} If `true`, this is a Mocha flag
109
+ * @private
110
+ */
111
+ exports.isMochaFlag = flag => {
112
+ return ALL_MOCHA_FLAGS.has(flag.replace(/^--?/, ''));
113
+ };
package/lib/mocha.js CHANGED
@@ -807,7 +807,7 @@ Mocha.prototype.slow = function(msecs) {
807
807
  *
808
808
  * @public
809
809
  * @see [CLI option](../#-async-only-a)
810
- * @param {boolean} [asyncOnly=true] - Wether to force `done` callback or promise.
810
+ * @param {boolean} [asyncOnly=true] - Whether to force `done` callback or promise.
811
811
  * @return {Mocha} this
812
812
  * @chainable
813
813
  */
@@ -847,7 +847,7 @@ Mocha.prototype.allowUncaught = function(allowUncaught) {
847
847
  * Delays root suite execution.
848
848
  *
849
849
  * @description
850
- * Used to perform asynch operations before any suites are run.
850
+ * Used to perform async operations before any suites are run.
851
851
  *
852
852
  * @public
853
853
  * @see [delayed root suite](../#delayed-root-suite)
@@ -56,7 +56,7 @@ class SerializableWorkerResult {
56
56
  /**
57
57
  * Instantiates a new {@link SerializableWorkerResult}.
58
58
  * @param {...any} args - Args to constructor
59
- * @returns {SerilizableWorkerResult}
59
+ * @returns {SerializableWorkerResult}
60
60
  */
61
61
  static create(...args) {
62
62
  return new SerializableWorkerResult(...args);
package/lib/runner.js CHANGED
@@ -206,7 +206,7 @@ Runner.prototype._addEventListener = function(target, eventName, listener) {
206
206
  /**
207
207
  * Replacement for `target.removeListener(eventName, listener)` that also updates the bookkeeping.
208
208
  * @param {EventEmitter} target - The `EventEmitter`
209
- * @param {string} eventName - The event anme
209
+ * @param {string} eventName - The event name
210
210
  * @param {function} listener - Listener function
211
211
  * @private
212
212
  */
package/lib/utils.js CHANGED
@@ -508,7 +508,7 @@ exports.isPromise = function isPromise(value) {
508
508
  * Clamps a numeric value to an inclusive range.
509
509
  *
510
510
  * @param {number} value - Value to be clamped.
511
- * @param {numer[]} range - Two element array specifying [min, max] range.
511
+ * @param {number[]} range - Two element array specifying [min, max] range.
512
512
  * @returns {number} clamped value
513
513
  */
514
514
  exports.clamp = function clamp(value, range) {
@@ -568,9 +568,9 @@ exports.noop = function() {};
568
568
  * doesn't support it. Recommended for use in Mocha's public APIs.
569
569
  *
570
570
  * @public
571
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map}
571
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Custom_and_Null_objects|MDN:Map}
572
572
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects}
573
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign}
573
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Custom_and_Null_objects|MDN:Object.assign}
574
574
  * @param {...*} [obj] - Arguments to `Object.assign()`.
575
575
  * @returns {Object} An object with no prototype, having `...obj` properties
576
576
  */
package/mocha.js CHANGED
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.mocha = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mocha = factory());
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -2946,6 +2946,39 @@
2946
2946
  return _typeof(obj);
2947
2947
  }
2948
2948
 
2949
+ function _toConsumableArray(arr) {
2950
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
2951
+ }
2952
+
2953
+ function _arrayWithoutHoles(arr) {
2954
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
2955
+ }
2956
+
2957
+ function _iterableToArray(iter) {
2958
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
2959
+ }
2960
+
2961
+ function _unsupportedIterableToArray(o, minLen) {
2962
+ if (!o) return;
2963
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2964
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2965
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2966
+ if (n === "Map" || n === "Set") return Array.from(o);
2967
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2968
+ }
2969
+
2970
+ function _arrayLikeToArray(arr, len) {
2971
+ if (len == null || len > arr.length) len = arr.length;
2972
+
2973
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2974
+
2975
+ return arr2;
2976
+ }
2977
+
2978
+ function _nonIterableSpread() {
2979
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2980
+ }
2981
+
2949
2982
  var f$6 = wellKnownSymbol;
2950
2983
 
2951
2984
  var wellKnownSymbolWrapped = {
@@ -9973,14 +10006,14 @@
9973
10006
  }
9974
10007
  });
9975
10008
 
9976
- var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
9977
-
9978
- var escapeStringRegexp = function escapeStringRegexp(str) {
9979
- if (typeof str !== 'string') {
10009
+ var escapeStringRegexp = function escapeStringRegexp(string) {
10010
+ if (typeof string !== 'string') {
9980
10011
  throw new TypeError('Expected a string');
9981
- }
10012
+ } // Escape characters with special meaning either inside or outside character sets.
10013
+ // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
10014
+
9982
10015
 
9983
- return str.replace(matchOperatorsRe, '\\$&');
10016
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
9984
10017
  };
9985
10018
 
9986
10019
  // Copyright Joyent, Inc. and other Node contributors.
@@ -17292,7 +17325,7 @@
17292
17325
  * Clamps a numeric value to an inclusive range.
17293
17326
  *
17294
17327
  * @param {number} value - Value to be clamped.
17295
- * @param {numer[]} range - Two element array specifying [min, max] range.
17328
+ * @param {number[]} range - Two element array specifying [min, max] range.
17296
17329
  * @returns {number} clamped value
17297
17330
  */
17298
17331
 
@@ -17356,9 +17389,9 @@
17356
17389
  * doesn't support it. Recommended for use in Mocha's public APIs.
17357
17390
  *
17358
17391
  * @public
17359
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map}
17392
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Custom_and_Null_objects|MDN:Map}
17360
17393
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects}
17361
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign}
17394
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Custom_and_Null_objects|MDN:Object.assign}
17362
17395
  * @param {...*} [obj] - Arguments to `Object.assign()`.
17363
17396
  * @returns {Object} An object with no prototype, having `...obj` properties
17364
17397
  */
@@ -17466,7 +17499,6 @@
17466
17499
  * implementations of `debug()`.
17467
17500
  */
17468
17501
 
17469
-
17470
17502
  function setup(env) {
17471
17503
  createDebug.debug = createDebug;
17472
17504
  createDebug["default"] = createDebug;
@@ -17527,15 +17559,15 @@
17527
17559
  var prevTime;
17528
17560
 
17529
17561
  function debug() {
17562
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17563
+ args[_key] = arguments[_key];
17564
+ }
17565
+
17530
17566
  // Disabled?
17531
17567
  if (!debug.enabled) {
17532
17568
  return;
17533
17569
  }
17534
17570
 
17535
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17536
- args[_key] = arguments[_key];
17537
- }
17538
-
17539
17571
  var self = debug; // Set `diff` timestamp
17540
17572
 
17541
17573
  var curr = Number(new Date());
@@ -17607,7 +17639,9 @@
17607
17639
  }
17608
17640
 
17609
17641
  function extend(namespace, delimiter) {
17610
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
17642
+ var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
17643
+ newDebug.log = this.log;
17644
+ return newDebug;
17611
17645
  }
17612
17646
  /**
17613
17647
  * Enables a debug mode by namespaces. This can include modes
@@ -17649,12 +17683,17 @@
17649
17683
  /**
17650
17684
  * Disable debug output.
17651
17685
  *
17686
+ * @return {String} namespaces
17652
17687
  * @api public
17653
17688
  */
17654
17689
 
17655
17690
 
17656
17691
  function disable() {
17692
+ var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) {
17693
+ return '-' + namespace;
17694
+ }))).join(',');
17657
17695
  createDebug.enable('');
17696
+ return namespaces;
17658
17697
  }
17659
17698
  /**
17660
17699
  * Returns true if the given mode name is enabled, false otherwise.
@@ -17688,6 +17727,18 @@
17688
17727
  return false;
17689
17728
  }
17690
17729
  /**
17730
+ * Convert regexp to namespace
17731
+ *
17732
+ * @param {RegExp} regxep
17733
+ * @return {String} namespace
17734
+ * @api private
17735
+ */
17736
+
17737
+
17738
+ function toNamespace(regexp) {
17739
+ return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
17740
+ }
17741
+ /**
17691
17742
  * Coerce `val`.
17692
17743
  *
17693
17744
  * @param {Mixed} val
@@ -17711,27 +17762,11 @@
17711
17762
  var common = setup;
17712
17763
 
17713
17764
  var browser$2 = createCommonjsModule(function (module, exports) {
17714
-
17715
- function _typeof$1(obj) {
17716
- if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
17717
- _typeof$1 = function _typeof$1(obj) {
17718
- return _typeof(obj);
17719
- };
17720
- } else {
17721
- _typeof$1 = function _typeof$1(obj) {
17722
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof(obj);
17723
- };
17724
- }
17725
-
17726
- return _typeof$1(obj);
17727
- }
17728
17765
  /* eslint-env browser */
17729
17766
 
17730
17767
  /**
17731
17768
  * This is the web browser implementation of `debug()`.
17732
17769
  */
17733
-
17734
-
17735
17770
  exports.log = log;
17736
17771
  exports.formatArgs = formatArgs;
17737
17772
  exports.save = save;
@@ -17818,11 +17853,11 @@
17818
17853
 
17819
17854
 
17820
17855
  function log() {
17821
- var _console; // This hackery is required for IE8/9, where
17822
- // the `console.log` function doesn't have 'apply'
17823
-
17856
+ var _console;
17824
17857
 
17825
- return (typeof console === "undefined" ? "undefined" : _typeof$1(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
17858
+ // This hackery is required for IE8/9, where
17859
+ // the `console.log` function doesn't have 'apply'
17860
+ return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
17826
17861
  }
17827
17862
  /**
17828
17863
  * Save `namespaces`.
@@ -17856,9 +17891,9 @@
17856
17891
 
17857
17892
  try {
17858
17893
  r = exports.storage.getItem('debug');
17859
- } catch (error) {} // Swallow
17860
- // XXX (@Qix-) should we be logging these?
17861
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
17894
+ } catch (error) {// Swallow
17895
+ // XXX (@Qix-) should we be logging these?
17896
+ } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
17862
17897
 
17863
17898
 
17864
17899
  if (!r && typeof process$1 !== 'undefined' && 'env' in process$1) {
@@ -19750,7 +19785,7 @@
19750
19785
  /**
19751
19786
  * Replacement for `target.removeListener(eventName, listener)` that also updates the bookkeeping.
19752
19787
  * @param {EventEmitter} target - The `EventEmitter`
19753
- * @param {string} eventName - The event anme
19788
+ * @param {string} eventName - The event name
19754
19789
  * @param {function} listener - Listener function
19755
19790
  * @private
19756
19791
  */
@@ -23506,7 +23541,7 @@
23506
23541
  });
23507
23542
 
23508
23543
  var name = "mocha";
23509
- var version$2 = "8.1.1";
23544
+ var version$2 = "8.1.2";
23510
23545
  var homepage = "https://mochajs.org/";
23511
23546
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
23512
23547
  var _package = {
@@ -25006,7 +25041,7 @@
25006
25041
 
25007
25042
 
25008
25043
  Mocha.unloadFile = function (file) {
25009
- delete commonjsRequire.cache[commonjsRequire.resolve(file)];
25044
+ delete require.cache[require.resolve(file)];
25010
25045
  };
25011
25046
  /**
25012
25047
  * Unloads `files` from Node's `require` cache.
@@ -25377,7 +25412,7 @@
25377
25412
  *
25378
25413
  * @public
25379
25414
  * @see [CLI option](../#-async-only-a)
25380
- * @param {boolean} [asyncOnly=true] - Wether to force `done` callback or promise.
25415
+ * @param {boolean} [asyncOnly=true] - Whether to force `done` callback or promise.
25381
25416
  * @return {Mocha} this
25382
25417
  * @chainable
25383
25418
  */
@@ -25420,7 +25455,7 @@
25420
25455
  * Delays root suite execution.
25421
25456
  *
25422
25457
  * @description
25423
- * Used to perform asynch operations before any suites are run.
25458
+ * Used to perform async operations before any suites are run.
25424
25459
  *
25425
25460
  * @public
25426
25461
  * @see [delayed root suite](../#delayed-root-suite)
@@ -25909,8 +25944,8 @@
25909
25944
  * Expose mocha.
25910
25945
  */
25911
25946
 
25912
- mocha$1.Mocha = mocha;
25913
- mocha$1.mocha = mocha$1; // this allows test/acceptance/required-tokens.js to pass; thus,
25947
+ commonjsGlobal.Mocha = mocha;
25948
+ commonjsGlobal.mocha = mocha$1; // this allows test/acceptance/required-tokens.js to pass; thus,
25914
25949
  // you can now do `const describe = require('mocha').describe` in a
25915
25950
  // browser context (assuming browserification). should fix #880
25916
25951