mocha 8.1.2 → 8.1.3

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/mocha.js CHANGED
@@ -16838,196 +16838,546 @@
16838
16838
  });
16839
16839
  var object_assign = polyfill$1;
16840
16840
 
16841
- var utils = createCommonjsModule(function (module, exports) {
16841
+ var format$1 = util.format;
16842
+ /**
16843
+ * Factory functions to create throwable error objects
16844
+ * @module Errors
16845
+ */
16846
+
16847
+ /**
16848
+ * When Mocha throw exceptions (or otherwise errors), it attempts to assign a
16849
+ * `code` property to the `Error` object, for easier handling. These are the
16850
+ * potential values of `code`.
16851
+ */
16852
+
16853
+ var constants = {
16842
16854
  /**
16843
- * Various utility functions used throughout Mocha's codebase.
16844
- * @module utils
16855
+ * An unrecoverable error.
16845
16856
  */
16857
+ FATAL: 'ERR_MOCHA_FATAL',
16846
16858
 
16847
16859
  /**
16848
- * Module dependencies.
16860
+ * The type of an argument to a function call is invalid
16849
16861
  */
16862
+ INVALID_ARG_TYPE: 'ERR_MOCHA_INVALID_ARG_TYPE',
16850
16863
 
16851
- var assign = exports.assign = object_assign.getPolyfill();
16852
16864
  /**
16853
- * Inherit the prototype methods from one constructor into another.
16854
- *
16855
- * @param {function} ctor - Constructor function which needs to inherit the
16856
- * prototype.
16857
- * @param {function} superCtor - Constructor function to inherit prototype from.
16858
- * @throws {TypeError} if either constructor is null, or if super constructor
16859
- * lacks a prototype.
16865
+ * The value of an argument to a function call is invalid
16860
16866
  */
16867
+ INVALID_ARG_VALUE: 'ERR_MOCHA_INVALID_ARG_VALUE',
16861
16868
 
16862
- exports.inherits = util.inherits;
16863
16869
  /**
16864
- * Escape special characters in the given string of html.
16865
- *
16866
- * @private
16867
- * @param {string} html
16868
- * @return {string}
16870
+ * Something was thrown, but it wasn't an `Error`
16869
16871
  */
16872
+ INVALID_EXCEPTION: 'ERR_MOCHA_INVALID_EXCEPTION',
16870
16873
 
16871
- exports.escape = function (html) {
16872
- return he.encode(String(html), {
16873
- useNamedReferences: false
16874
- });
16875
- };
16876
16874
  /**
16877
- * Test if the given obj is type of string.
16878
- *
16879
- * @private
16880
- * @param {Object} obj
16881
- * @return {boolean}
16875
+ * An interface (e.g., `Mocha.interfaces`) is unknown or invalid
16882
16876
  */
16877
+ INVALID_INTERFACE: 'ERR_MOCHA_INVALID_INTERFACE',
16883
16878
 
16884
-
16885
- exports.isString = function (obj) {
16886
- return typeof obj === 'string';
16887
- };
16888
16879
  /**
16889
- * Compute a slug from the given `str`.
16890
- *
16891
- * @private
16892
- * @param {string} str
16893
- * @return {string}
16880
+ * A reporter (.e.g, `Mocha.reporters`) is unknown or invalid
16894
16881
  */
16882
+ INVALID_REPORTER: 'ERR_MOCHA_INVALID_REPORTER',
16895
16883
 
16896
-
16897
- exports.slug = function (str) {
16898
- return str.toLowerCase().replace(/\s+/g, '-').replace(/[^-\w]/g, '').replace(/-{2,}/g, '-');
16899
- };
16900
16884
  /**
16901
- * Strip the function definition from `str`, and re-indent for pre whitespace.
16902
- *
16903
- * @param {string} str
16904
- * @return {string}
16885
+ * `done()` was called twice in a `Test` or `Hook` callback
16905
16886
  */
16887
+ MULTIPLE_DONE: 'ERR_MOCHA_MULTIPLE_DONE',
16906
16888
 
16907
-
16908
- exports.clean = function (str) {
16909
- str = str.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '') // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
16910
- .replace(/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, '$1$2$3');
16911
- var spaces = str.match(/^\n?( *)/)[1].length;
16912
- var tabs = str.match(/^\n?(\t*)/)[1].length;
16913
- var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');
16914
- str = str.replace(re, '');
16915
- return str.trim();
16916
- };
16917
16889
  /**
16918
- * If a value could have properties, and has none, this function is called,
16919
- * which returns a string representation of the empty value.
16920
- *
16921
- * Functions w/ no properties return `'[Function]'`
16922
- * Arrays w/ length === 0 return `'[]'`
16923
- * Objects w/ no properties return `'{}'`
16924
- * All else: return result of `value.toString()`
16925
- *
16926
- * @private
16927
- * @param {*} value The value to inspect.
16928
- * @param {string} typeHint The type of the value
16929
- * @returns {string}
16890
+ * No files matched the pattern provided by the user
16930
16891
  */
16892
+ NO_FILES_MATCH_PATTERN: 'ERR_MOCHA_NO_FILES_MATCH_PATTERN',
16931
16893
 
16932
-
16933
- function emptyRepresentation(value, typeHint) {
16934
- switch (typeHint) {
16935
- case 'function':
16936
- return '[Function]';
16937
-
16938
- case 'object':
16939
- return '{}';
16940
-
16941
- case 'array':
16942
- return '[]';
16943
-
16944
- default:
16945
- return value.toString();
16946
- }
16947
- }
16948
16894
  /**
16949
- * Takes some variable and asks `Object.prototype.toString()` what it thinks it
16950
- * is.
16951
- *
16952
- * @private
16953
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
16954
- * @param {*} value The value to test.
16955
- * @returns {string} Computed type
16956
- * @example
16957
- * type({}) // 'object'
16958
- * type([]) // 'array'
16959
- * type(1) // 'number'
16960
- * type(false) // 'boolean'
16961
- * type(Infinity) // 'number'
16962
- * type(null) // 'null'
16963
- * type(new Date()) // 'date'
16964
- * type(/foo/) // 'regexp'
16965
- * type('type') // 'string'
16966
- * type(global) // 'global'
16967
- * type(new String('foo') // 'object'
16895
+ * Known, but unsupported behavior of some kind
16968
16896
  */
16897
+ UNSUPPORTED: 'ERR_MOCHA_UNSUPPORTED',
16969
16898
 
16899
+ /**
16900
+ * Invalid state transition occurring in `Mocha` instance
16901
+ */
16902
+ INSTANCE_ALREADY_RUNNING: 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING',
16970
16903
 
16971
- var type = exports.type = function type(value) {
16972
- if (value === undefined) {
16973
- return 'undefined';
16974
- } else if (value === null) {
16975
- return 'null';
16976
- } else if (isBuffer(value)) {
16977
- return 'buffer';
16978
- }
16904
+ /**
16905
+ * Invalid state transition occurring in `Mocha` instance
16906
+ */
16907
+ INSTANCE_ALREADY_DISPOSED: 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED',
16979
16908
 
16980
- return Object.prototype.toString.call(value).replace(/^\[.+\s(.+?)]$/, '$1').toLowerCase();
16981
- };
16982
16909
  /**
16983
- * Stringify `value`. Different behavior depending on type of value:
16984
- *
16985
- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
16986
- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
16987
- * - If `value` is an *empty* object, function, or array, return result of function
16988
- * {@link emptyRepresentation}.
16989
- * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
16990
- * JSON.stringify().
16991
- *
16992
- * @private
16993
- * @see exports.type
16994
- * @param {*} value
16995
- * @return {string}
16910
+ * Use of `only()` w/ `--forbid-only` results in this error.
16996
16911
  */
16912
+ FORBIDDEN_EXCLUSIVITY: 'ERR_MOCHA_FORBIDDEN_EXCLUSIVITY'
16913
+ };
16914
+ /**
16915
+ * Creates an error object to be thrown when no files to be tested could be found using specified pattern.
16916
+ *
16917
+ * @public
16918
+ * @param {string} message - Error message to be displayed.
16919
+ * @param {string} pattern - User-specified argument value.
16920
+ * @returns {Error} instance detailing the error condition
16921
+ */
16997
16922
 
16923
+ function createNoFilesMatchPatternError(message, pattern) {
16924
+ var err = new Error(message);
16925
+ err.code = constants.NO_FILES_MATCH_PATTERN;
16926
+ err.pattern = pattern;
16927
+ return err;
16928
+ }
16929
+ /**
16930
+ * Creates an error object to be thrown when the reporter specified in the options was not found.
16931
+ *
16932
+ * @public
16933
+ * @param {string} message - Error message to be displayed.
16934
+ * @param {string} reporter - User-specified reporter value.
16935
+ * @returns {Error} instance detailing the error condition
16936
+ */
16998
16937
 
16999
- exports.stringify = function (value) {
17000
- var typeHint = type(value);
17001
16938
 
17002
- if (!~['object', 'array', 'function'].indexOf(typeHint)) {
17003
- if (typeHint === 'buffer') {
17004
- var json = Buffer.prototype.toJSON.call(value); // Based on the toJSON result
16939
+ function createInvalidReporterError(message, reporter) {
16940
+ var err = new TypeError(message);
16941
+ err.code = constants.INVALID_REPORTER;
16942
+ err.reporter = reporter;
16943
+ return err;
16944
+ }
16945
+ /**
16946
+ * Creates an error object to be thrown when the interface specified in the options was not found.
16947
+ *
16948
+ * @public
16949
+ * @param {string} message - Error message to be displayed.
16950
+ * @param {string} ui - User-specified interface value.
16951
+ * @returns {Error} instance detailing the error condition
16952
+ */
17005
16953
 
17006
- return jsonStringify(json.data && json.type ? json.data : json, 2).replace(/,(\n|$)/g, '$1');
17007
- } // IE7/IE8 has a bizarre String constructor; needs to be coerced
17008
- // into an array and back to obj.
17009
16954
 
16955
+ function createInvalidInterfaceError(message, ui) {
16956
+ var err = new Error(message);
16957
+ err.code = constants.INVALID_INTERFACE;
16958
+ err["interface"] = ui;
16959
+ return err;
16960
+ }
16961
+ /**
16962
+ * Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
16963
+ *
16964
+ * @public
16965
+ * @param {string} message - Error message to be displayed.
16966
+ * @returns {Error} instance detailing the error condition
16967
+ */
17010
16968
 
17011
- if (typeHint === 'string' && _typeof(value) === 'object') {
17012
- value = value.split('').reduce(function (acc, _char, idx) {
17013
- acc[idx] = _char;
17014
- return acc;
17015
- }, {});
17016
- typeHint = 'object';
17017
- } else {
17018
- return jsonStringify(value);
17019
- }
17020
- }
17021
16969
 
17022
- for (var prop in value) {
17023
- if (Object.prototype.hasOwnProperty.call(value, prop)) {
17024
- return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1');
17025
- }
17026
- }
16970
+ function createUnsupportedError(message) {
16971
+ var err = new Error(message);
16972
+ err.code = constants.UNSUPPORTED;
16973
+ return err;
16974
+ }
16975
+ /**
16976
+ * Creates an error object to be thrown when an argument is missing.
16977
+ *
16978
+ * @public
16979
+ * @param {string} message - Error message to be displayed.
16980
+ * @param {string} argument - Argument name.
16981
+ * @param {string} expected - Expected argument datatype.
16982
+ * @returns {Error} instance detailing the error condition
16983
+ */
17027
16984
 
17028
- return emptyRepresentation(value, typeHint);
17029
- };
17030
- /**
16985
+
16986
+ function createMissingArgumentError(message, argument, expected) {
16987
+ return createInvalidArgumentTypeError(message, argument, expected);
16988
+ }
16989
+ /**
16990
+ * Creates an error object to be thrown when an argument did not use the supported type
16991
+ *
16992
+ * @public
16993
+ * @param {string} message - Error message to be displayed.
16994
+ * @param {string} argument - Argument name.
16995
+ * @param {string} expected - Expected argument datatype.
16996
+ * @returns {Error} instance detailing the error condition
16997
+ */
16998
+
16999
+
17000
+ function createInvalidArgumentTypeError(message, argument, expected) {
17001
+ var err = new TypeError(message);
17002
+ err.code = constants.INVALID_ARG_TYPE;
17003
+ err.argument = argument;
17004
+ err.expected = expected;
17005
+ err.actual = _typeof(argument);
17006
+ return err;
17007
+ }
17008
+ /**
17009
+ * Creates an error object to be thrown when an argument did not use the supported value
17010
+ *
17011
+ * @public
17012
+ * @param {string} message - Error message to be displayed.
17013
+ * @param {string} argument - Argument name.
17014
+ * @param {string} value - Argument value.
17015
+ * @param {string} [reason] - Why value is invalid.
17016
+ * @returns {Error} instance detailing the error condition
17017
+ */
17018
+
17019
+
17020
+ function createInvalidArgumentValueError(message, argument, value, reason) {
17021
+ var err = new TypeError(message);
17022
+ err.code = constants.INVALID_ARG_VALUE;
17023
+ err.argument = argument;
17024
+ err.value = value;
17025
+ err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
17026
+ return err;
17027
+ }
17028
+ /**
17029
+ * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
17030
+ *
17031
+ * @public
17032
+ * @param {string} message - Error message to be displayed.
17033
+ * @returns {Error} instance detailing the error condition
17034
+ */
17035
+
17036
+
17037
+ function createInvalidExceptionError(message, value) {
17038
+ var err = new Error(message);
17039
+ err.code = constants.INVALID_EXCEPTION;
17040
+ err.valueType = _typeof(value);
17041
+ err.value = value;
17042
+ return err;
17043
+ }
17044
+ /**
17045
+ * Creates an error object to be thrown when an unrecoverable error occurs.
17046
+ *
17047
+ * @public
17048
+ * @param {string} message - Error message to be displayed.
17049
+ * @returns {Error} instance detailing the error condition
17050
+ */
17051
+
17052
+
17053
+ function createFatalError(message, value) {
17054
+ var err = new Error(message);
17055
+ err.code = constants.FATAL;
17056
+ err.valueType = _typeof(value);
17057
+ err.value = value;
17058
+ return err;
17059
+ }
17060
+ /**
17061
+ * Dynamically creates a plugin-type-specific error based on plugin type
17062
+ * @param {string} message - Error message
17063
+ * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
17064
+ * @param {string} [pluginId] - Name/path of plugin, if any
17065
+ * @throws When `pluginType` is not known
17066
+ * @public
17067
+ * @returns {Error}
17068
+ */
17069
+
17070
+
17071
+ function createInvalidPluginError(message, pluginType, pluginId) {
17072
+ switch (pluginType) {
17073
+ case 'reporter':
17074
+ return createInvalidReporterError(message, pluginId);
17075
+
17076
+ case 'interface':
17077
+ return createInvalidInterfaceError(message, pluginId);
17078
+
17079
+ default:
17080
+ throw new Error('unknown pluginType "' + pluginType + '"');
17081
+ }
17082
+ }
17083
+ /**
17084
+ * Creates an error object to be thrown when a mocha object's `run` method is executed while it is already disposed.
17085
+ * @param {string} message The error message to be displayed.
17086
+ * @param {boolean} cleanReferencesAfterRun the value of `cleanReferencesAfterRun`
17087
+ * @param {Mocha} instance the mocha instance that throw this error
17088
+ */
17089
+
17090
+
17091
+ function createMochaInstanceAlreadyDisposedError(message, cleanReferencesAfterRun, instance) {
17092
+ var err = new Error(message);
17093
+ err.code = constants.INSTANCE_ALREADY_DISPOSED;
17094
+ err.cleanReferencesAfterRun = cleanReferencesAfterRun;
17095
+ err.instance = instance;
17096
+ return err;
17097
+ }
17098
+ /**
17099
+ * Creates an error object to be thrown when a mocha object's `run` method is called while a test run is in progress.
17100
+ * @param {string} message The error message to be displayed.
17101
+ */
17102
+
17103
+
17104
+ function createMochaInstanceAlreadyRunningError(message, instance) {
17105
+ var err = new Error(message);
17106
+ err.code = constants.INSTANCE_ALREADY_RUNNING;
17107
+ err.instance = instance;
17108
+ return err;
17109
+ }
17110
+ /*
17111
+ * Creates an error object to be thrown when done() is called multiple times in a test
17112
+ *
17113
+ * @public
17114
+ * @param {Runnable} runnable - Original runnable
17115
+ * @param {Error} [originalErr] - Original error, if any
17116
+ * @returns {Error} instance detailing the error condition
17117
+ */
17118
+
17119
+
17120
+ function createMultipleDoneError(runnable, originalErr) {
17121
+ var title;
17122
+
17123
+ try {
17124
+ title = format$1('<%s>', runnable.fullTitle());
17125
+
17126
+ if (runnable.parent.root) {
17127
+ title += ' (of root suite)';
17128
+ }
17129
+ } catch (ignored) {
17130
+ title = format$1('<%s> (of unknown suite)', runnable.title);
17131
+ }
17132
+
17133
+ var message = format$1('done() called multiple times in %s %s', runnable.type ? runnable.type : 'unknown runnable', title);
17134
+
17135
+ if (runnable.file) {
17136
+ message += format$1(' of file %s', runnable.file);
17137
+ }
17138
+
17139
+ if (originalErr) {
17140
+ message += format$1('; in addition, done() received error: %s', originalErr);
17141
+ }
17142
+
17143
+ var err = new Error(message);
17144
+ err.code = constants.MULTIPLE_DONE;
17145
+ err.valueType = _typeof(originalErr);
17146
+ err.value = originalErr;
17147
+ return err;
17148
+ }
17149
+ /**
17150
+ * Creates an error object to be thrown when `.only()` is used with
17151
+ * `--forbid-only`.
17152
+ * @public
17153
+ * @param {Mocha} mocha - Mocha instance
17154
+ * @returns {Error} Error with code {@link constants.FORBIDDEN_EXCLUSIVITY}
17155
+ */
17156
+
17157
+
17158
+ function createForbiddenExclusivityError(mocha) {
17159
+ var err = new Error(mocha.isWorker ? '`.only` is not supported in parallel mode' : '`.only` forbidden by --forbid-only');
17160
+ err.code = constants.FORBIDDEN_EXCLUSIVITY;
17161
+ return err;
17162
+ }
17163
+
17164
+ var errors = {
17165
+ createInvalidArgumentTypeError: createInvalidArgumentTypeError,
17166
+ createInvalidArgumentValueError: createInvalidArgumentValueError,
17167
+ createInvalidExceptionError: createInvalidExceptionError,
17168
+ createInvalidInterfaceError: createInvalidInterfaceError,
17169
+ createInvalidReporterError: createInvalidReporterError,
17170
+ createMissingArgumentError: createMissingArgumentError,
17171
+ createNoFilesMatchPatternError: createNoFilesMatchPatternError,
17172
+ createUnsupportedError: createUnsupportedError,
17173
+ createInvalidPluginError: createInvalidPluginError,
17174
+ createMochaInstanceAlreadyDisposedError: createMochaInstanceAlreadyDisposedError,
17175
+ createMochaInstanceAlreadyRunningError: createMochaInstanceAlreadyRunningError,
17176
+ createFatalError: createFatalError,
17177
+ createMultipleDoneError: createMultipleDoneError,
17178
+ createForbiddenExclusivityError: createForbiddenExclusivityError,
17179
+ constants: constants
17180
+ };
17181
+
17182
+ var _nodeResolve_empty = {};
17183
+
17184
+ var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
17185
+ __proto__: null,
17186
+ 'default': _nodeResolve_empty
17187
+ });
17188
+
17189
+ var require$$11 = getCjsExportFromNamespace(_nodeResolve_empty$1);
17190
+
17191
+ var utils = createCommonjsModule(function (module, exports) {
17192
+ /**
17193
+ * Various utility functions used throughout Mocha's codebase.
17194
+ * @module utils
17195
+ */
17196
+
17197
+ /**
17198
+ * Module dependencies.
17199
+ */
17200
+
17201
+ var assign = exports.assign = object_assign.getPolyfill();
17202
+ /**
17203
+ * Inherit the prototype methods from one constructor into another.
17204
+ *
17205
+ * @param {function} ctor - Constructor function which needs to inherit the
17206
+ * prototype.
17207
+ * @param {function} superCtor - Constructor function to inherit prototype from.
17208
+ * @throws {TypeError} if either constructor is null, or if super constructor
17209
+ * lacks a prototype.
17210
+ */
17211
+
17212
+ exports.inherits = util.inherits;
17213
+ /**
17214
+ * Escape special characters in the given string of html.
17215
+ *
17216
+ * @private
17217
+ * @param {string} html
17218
+ * @return {string}
17219
+ */
17220
+
17221
+ exports.escape = function (html) {
17222
+ return he.encode(String(html), {
17223
+ useNamedReferences: false
17224
+ });
17225
+ };
17226
+ /**
17227
+ * Test if the given obj is type of string.
17228
+ *
17229
+ * @private
17230
+ * @param {Object} obj
17231
+ * @return {boolean}
17232
+ */
17233
+
17234
+
17235
+ exports.isString = function (obj) {
17236
+ return typeof obj === 'string';
17237
+ };
17238
+ /**
17239
+ * Compute a slug from the given `str`.
17240
+ *
17241
+ * @private
17242
+ * @param {string} str
17243
+ * @return {string}
17244
+ */
17245
+
17246
+
17247
+ exports.slug = function (str) {
17248
+ return str.toLowerCase().replace(/\s+/g, '-').replace(/[^-\w]/g, '').replace(/-{2,}/g, '-');
17249
+ };
17250
+ /**
17251
+ * Strip the function definition from `str`, and re-indent for pre whitespace.
17252
+ *
17253
+ * @param {string} str
17254
+ * @return {string}
17255
+ */
17256
+
17257
+
17258
+ exports.clean = function (str) {
17259
+ str = str.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '') // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
17260
+ .replace(/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, '$1$2$3');
17261
+ var spaces = str.match(/^\n?( *)/)[1].length;
17262
+ var tabs = str.match(/^\n?(\t*)/)[1].length;
17263
+ var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');
17264
+ str = str.replace(re, '');
17265
+ return str.trim();
17266
+ };
17267
+ /**
17268
+ * If a value could have properties, and has none, this function is called,
17269
+ * which returns a string representation of the empty value.
17270
+ *
17271
+ * Functions w/ no properties return `'[Function]'`
17272
+ * Arrays w/ length === 0 return `'[]'`
17273
+ * Objects w/ no properties return `'{}'`
17274
+ * All else: return result of `value.toString()`
17275
+ *
17276
+ * @private
17277
+ * @param {*} value The value to inspect.
17278
+ * @param {string} typeHint The type of the value
17279
+ * @returns {string}
17280
+ */
17281
+
17282
+
17283
+ function emptyRepresentation(value, typeHint) {
17284
+ switch (typeHint) {
17285
+ case 'function':
17286
+ return '[Function]';
17287
+
17288
+ case 'object':
17289
+ return '{}';
17290
+
17291
+ case 'array':
17292
+ return '[]';
17293
+
17294
+ default:
17295
+ return value.toString();
17296
+ }
17297
+ }
17298
+ /**
17299
+ * Takes some variable and asks `Object.prototype.toString()` what it thinks it
17300
+ * is.
17301
+ *
17302
+ * @private
17303
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
17304
+ * @param {*} value The value to test.
17305
+ * @returns {string} Computed type
17306
+ * @example
17307
+ * type({}) // 'object'
17308
+ * type([]) // 'array'
17309
+ * type(1) // 'number'
17310
+ * type(false) // 'boolean'
17311
+ * type(Infinity) // 'number'
17312
+ * type(null) // 'null'
17313
+ * type(new Date()) // 'date'
17314
+ * type(/foo/) // 'regexp'
17315
+ * type('type') // 'string'
17316
+ * type(global) // 'global'
17317
+ * type(new String('foo') // 'object'
17318
+ */
17319
+
17320
+
17321
+ var type = exports.type = function type(value) {
17322
+ if (value === undefined) {
17323
+ return 'undefined';
17324
+ } else if (value === null) {
17325
+ return 'null';
17326
+ } else if (isBuffer(value)) {
17327
+ return 'buffer';
17328
+ }
17329
+
17330
+ return Object.prototype.toString.call(value).replace(/^\[.+\s(.+?)]$/, '$1').toLowerCase();
17331
+ };
17332
+ /**
17333
+ * Stringify `value`. Different behavior depending on type of value:
17334
+ *
17335
+ * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
17336
+ * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
17337
+ * - If `value` is an *empty* object, function, or array, return result of function
17338
+ * {@link emptyRepresentation}.
17339
+ * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
17340
+ * JSON.stringify().
17341
+ *
17342
+ * @private
17343
+ * @see exports.type
17344
+ * @param {*} value
17345
+ * @return {string}
17346
+ */
17347
+
17348
+
17349
+ exports.stringify = function (value) {
17350
+ var typeHint = type(value);
17351
+
17352
+ if (!~['object', 'array', 'function'].indexOf(typeHint)) {
17353
+ if (typeHint === 'buffer') {
17354
+ var json = Buffer.prototype.toJSON.call(value); // Based on the toJSON result
17355
+
17356
+ return jsonStringify(json.data && json.type ? json.data : json, 2).replace(/,(\n|$)/g, '$1');
17357
+ } // IE7/IE8 has a bizarre String constructor; needs to be coerced
17358
+ // into an array and back to obj.
17359
+
17360
+
17361
+ if (typeHint === 'string' && _typeof(value) === 'object') {
17362
+ value = value.split('').reduce(function (acc, _char, idx) {
17363
+ acc[idx] = _char;
17364
+ return acc;
17365
+ }, {});
17366
+ typeHint = 'object';
17367
+ } else {
17368
+ return jsonStringify(value);
17369
+ }
17370
+ }
17371
+
17372
+ for (var prop in value) {
17373
+ if (Object.prototype.hasOwnProperty.call(value, prop)) {
17374
+ return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1');
17375
+ }
17376
+ }
17377
+
17378
+ return emptyRepresentation(value, typeHint);
17379
+ };
17380
+ /**
17031
17381
  * like JSON.stringify but more sense.
17032
17382
  *
17033
17383
  * @private
@@ -17470,13 +17820,33 @@
17470
17820
  exports.isBrowser = function isBrowser() {
17471
17821
  return Boolean(browser$1);
17472
17822
  };
17473
- });
17823
+ /**
17824
+ * Lookup file names at the given `path`.
17825
+ *
17826
+ * @description
17827
+ * Filenames are returned in _traversal_ order by the OS/filesystem.
17828
+ * **Make no assumption that the names will be sorted in any fashion.**
17829
+ *
17830
+ * @public
17831
+ * @alias module:lib/cli.lookupFiles
17832
+ * @param {string} filepath - Base path to start searching from.
17833
+ * @param {string[]} [extensions=[]] - File extensions to look for.
17834
+ * @param {boolean} [recursive=false] - Whether to recurse into subdirectories.
17835
+ * @return {string[]} An array of paths.
17836
+ * @throws {Error} if no files match pattern.
17837
+ * @throws {TypeError} if `filepath` is directory and `extensions` not provided.
17838
+ * @deprecated Moved to {@link module:lib/cli.lookupFiles}
17839
+ */
17474
17840
 
17475
- var _nodeResolve_empty = {};
17476
17841
 
17477
- var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
17478
- __proto__: null,
17479
- 'default': _nodeResolve_empty
17842
+ exports.lookupFiles = function () {
17843
+ if (exports.isBrowser()) {
17844
+ throw errors.createUnsupportedError('lookupFiles() is only supported in Node.js!');
17845
+ }
17846
+
17847
+ exports.deprecate('`lookupFiles()` in module `mocha/lib/utils` has moved to module `mocha/lib/cli` and will be removed in the next major revision of Mocha');
17848
+ return require$$11.lookupFiles.apply(require$$11, arguments);
17849
+ };
17480
17850
  });
17481
17851
 
17482
17852
  /**
@@ -17696,589 +18066,248 @@
17696
18066
  return namespaces;
17697
18067
  }
17698
18068
  /**
17699
- * Returns true if the given mode name is enabled, false otherwise.
17700
- *
17701
- * @param {String} name
17702
- * @return {Boolean}
17703
- * @api public
17704
- */
17705
-
17706
-
17707
- function enabled(name) {
17708
- if (name[name.length - 1] === '*') {
17709
- return true;
17710
- }
17711
-
17712
- var i;
17713
- var len;
17714
-
17715
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
17716
- if (createDebug.skips[i].test(name)) {
17717
- return false;
17718
- }
17719
- }
17720
-
17721
- for (i = 0, len = createDebug.names.length; i < len; i++) {
17722
- if (createDebug.names[i].test(name)) {
17723
- return true;
17724
- }
17725
- }
17726
-
17727
- return false;
17728
- }
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
- /**
17742
- * Coerce `val`.
17743
- *
17744
- * @param {Mixed} val
17745
- * @return {Mixed}
17746
- * @api private
17747
- */
17748
-
17749
-
17750
- function coerce(val) {
17751
- if (val instanceof Error) {
17752
- return val.stack || val.message;
17753
- }
17754
-
17755
- return val;
17756
- }
17757
-
17758
- createDebug.enable(createDebug.load());
17759
- return createDebug;
17760
- }
17761
-
17762
- var common = setup;
17763
-
17764
- var browser$2 = createCommonjsModule(function (module, exports) {
17765
- /* eslint-env browser */
17766
-
17767
- /**
17768
- * This is the web browser implementation of `debug()`.
17769
- */
17770
- exports.log = log;
17771
- exports.formatArgs = formatArgs;
17772
- exports.save = save;
17773
- exports.load = load;
17774
- exports.useColors = useColors;
17775
- exports.storage = localstorage();
17776
- /**
17777
- * Colors.
17778
- */
17779
-
17780
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
17781
- /**
17782
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
17783
- * and the Firebug extension (any Firefox version) are known
17784
- * to support "%c" CSS customizations.
17785
- *
17786
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
17787
- */
17788
- // eslint-disable-next-line complexity
17789
-
17790
- function useColors() {
17791
- // NB: In an Electron preload script, document will be defined but not fully
17792
- // initialized. Since we know we're in Chrome, we'll just detect this case
17793
- // explicitly
17794
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
17795
- return true;
17796
- } // Internet Explorer and Edge do not support colors.
17797
-
17798
-
17799
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
17800
- return false;
17801
- } // Is webkit? http://stackoverflow.com/a/16459606/376773
17802
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
17803
-
17804
-
17805
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
17806
- typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
17807
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
17808
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
17809
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
17810
- }
17811
- /**
17812
- * Colorize log arguments if enabled.
17813
- *
17814
- * @api public
17815
- */
17816
-
17817
-
17818
- function formatArgs(args) {
17819
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
17820
-
17821
- if (!this.useColors) {
17822
- return;
17823
- }
17824
-
17825
- var c = 'color: ' + this.color;
17826
- args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
17827
- // arguments passed either before or after the %c, so we need to
17828
- // figure out the correct index to insert the CSS into
17829
-
17830
- var index = 0;
17831
- var lastC = 0;
17832
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
17833
- if (match === '%%') {
17834
- return;
17835
- }
17836
-
17837
- index++;
17838
-
17839
- if (match === '%c') {
17840
- // We only are interested in the *last* %c
17841
- // (the user may have provided their own)
17842
- lastC = index;
17843
- }
17844
- });
17845
- args.splice(lastC, 0, c);
17846
- }
17847
- /**
17848
- * Invokes `console.log()` when available.
17849
- * No-op when `console.log` is not a "function".
17850
- *
17851
- * @api public
17852
- */
17853
-
17854
-
17855
- function log() {
17856
- var _console;
17857
-
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);
17861
- }
17862
- /**
17863
- * Save `namespaces`.
17864
- *
17865
- * @param {String} namespaces
17866
- * @api private
17867
- */
17868
-
17869
-
17870
- function save(namespaces) {
17871
- try {
17872
- if (namespaces) {
17873
- exports.storage.setItem('debug', namespaces);
17874
- } else {
17875
- exports.storage.removeItem('debug');
17876
- }
17877
- } catch (error) {// Swallow
17878
- // XXX (@Qix-) should we be logging these?
17879
- }
17880
- }
17881
- /**
17882
- * Load `namespaces`.
17883
- *
17884
- * @return {String} returns the previously persisted debug modes
17885
- * @api private
17886
- */
17887
-
17888
-
17889
- function load() {
17890
- var r;
17891
-
17892
- try {
17893
- r = exports.storage.getItem('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
17897
-
17898
-
17899
- if (!r && typeof process$1 !== 'undefined' && 'env' in process$1) {
17900
- r = process$1.env.DEBUG;
17901
- }
17902
-
17903
- return r;
17904
- }
17905
- /**
17906
- * Localstorage attempts to return the localstorage.
17907
- *
17908
- * This is necessary because safari throws
17909
- * when a user disables cookies/localstorage
17910
- * and you attempt to access it.
17911
- *
17912
- * @return {LocalStorage}
17913
- * @api private
17914
- */
18069
+ * Returns true if the given mode name is enabled, false otherwise.
18070
+ *
18071
+ * @param {String} name
18072
+ * @return {Boolean}
18073
+ * @api public
18074
+ */
17915
18075
 
17916
18076
 
17917
- function localstorage() {
17918
- try {
17919
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
17920
- // The Browser also has localStorage in the global context.
17921
- return localStorage;
17922
- } catch (error) {// Swallow
17923
- // XXX (@Qix-) should we be logging these?
18077
+ function enabled(name) {
18078
+ if (name[name.length - 1] === '*') {
18079
+ return true;
17924
18080
  }
17925
- }
17926
18081
 
17927
- module.exports = common(exports);
17928
- var formatters = module.exports.formatters;
17929
- /**
17930
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
17931
- */
18082
+ var i;
18083
+ var len;
17932
18084
 
17933
- formatters.j = function (v) {
17934
- try {
17935
- return JSON.stringify(v);
17936
- } catch (error) {
17937
- return '[UnexpectedJSONParseError]: ' + error.message;
18085
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
18086
+ if (createDebug.skips[i].test(name)) {
18087
+ return false;
18088
+ }
17938
18089
  }
17939
- };
17940
- });
17941
-
17942
- var format$1 = util.format;
17943
- /**
17944
- * Factory functions to create throwable error objects
17945
- * @module Errors
17946
- */
17947
18090
 
17948
- /**
17949
- * When Mocha throw exceptions (or otherwise errors), it attempts to assign a
17950
- * `code` property to the `Error` object, for easier handling. These are the
17951
- * potential values of `code`.
17952
- */
18091
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
18092
+ if (createDebug.names[i].test(name)) {
18093
+ return true;
18094
+ }
18095
+ }
17953
18096
 
17954
- var constants = {
18097
+ return false;
18098
+ }
17955
18099
  /**
17956
- * An unrecoverable error.
17957
- */
17958
- FATAL: 'ERR_MOCHA_FATAL',
18100
+ * Convert regexp to namespace
18101
+ *
18102
+ * @param {RegExp} regxep
18103
+ * @return {String} namespace
18104
+ * @api private
18105
+ */
17959
18106
 
17960
- /**
17961
- * The type of an argument to a function call is invalid
17962
- */
17963
- INVALID_ARG_TYPE: 'ERR_MOCHA_INVALID_ARG_TYPE',
17964
18107
 
18108
+ function toNamespace(regexp) {
18109
+ return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
18110
+ }
17965
18111
  /**
17966
- * The value of an argument to a function call is invalid
17967
- */
17968
- INVALID_ARG_VALUE: 'ERR_MOCHA_INVALID_ARG_VALUE',
18112
+ * Coerce `val`.
18113
+ *
18114
+ * @param {Mixed} val
18115
+ * @return {Mixed}
18116
+ * @api private
18117
+ */
17969
18118
 
17970
- /**
17971
- * Something was thrown, but it wasn't an `Error`
17972
- */
17973
- INVALID_EXCEPTION: 'ERR_MOCHA_INVALID_EXCEPTION',
17974
18119
 
17975
- /**
17976
- * An interface (e.g., `Mocha.interfaces`) is unknown or invalid
17977
- */
17978
- INVALID_INTERFACE: 'ERR_MOCHA_INVALID_INTERFACE',
18120
+ function coerce(val) {
18121
+ if (val instanceof Error) {
18122
+ return val.stack || val.message;
18123
+ }
17979
18124
 
17980
- /**
17981
- * A reporter (.e.g, `Mocha.reporters`) is unknown or invalid
17982
- */
17983
- INVALID_REPORTER: 'ERR_MOCHA_INVALID_REPORTER',
18125
+ return val;
18126
+ }
17984
18127
 
17985
- /**
17986
- * `done()` was called twice in a `Test` or `Hook` callback
17987
- */
17988
- MULTIPLE_DONE: 'ERR_MOCHA_MULTIPLE_DONE',
18128
+ createDebug.enable(createDebug.load());
18129
+ return createDebug;
18130
+ }
17989
18131
 
17990
- /**
17991
- * No files matched the pattern provided by the user
17992
- */
17993
- NO_FILES_MATCH_PATTERN: 'ERR_MOCHA_NO_FILES_MATCH_PATTERN',
18132
+ var common = setup;
17994
18133
 
17995
- /**
17996
- * Known, but unsupported behavior of some kind
17997
- */
17998
- UNSUPPORTED: 'ERR_MOCHA_UNSUPPORTED',
18134
+ var browser$2 = createCommonjsModule(function (module, exports) {
18135
+ /* eslint-env browser */
17999
18136
 
18000
18137
  /**
18001
- * Invalid state transition occurring in `Mocha` instance
18138
+ * This is the web browser implementation of `debug()`.
18002
18139
  */
18003
- INSTANCE_ALREADY_RUNNING: 'ERR_MOCHA_INSTANCE_ALREADY_RUNNING',
18004
-
18140
+ exports.log = log;
18141
+ exports.formatArgs = formatArgs;
18142
+ exports.save = save;
18143
+ exports.load = load;
18144
+ exports.useColors = useColors;
18145
+ exports.storage = localstorage();
18005
18146
  /**
18006
- * Invalid state transition occurring in `Mocha` instance
18147
+ * Colors.
18007
18148
  */
18008
- INSTANCE_ALREADY_DISPOSED: 'ERR_MOCHA_INSTANCE_ALREADY_DISPOSED',
18009
18149
 
18150
+ exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
18010
18151
  /**
18011
- * Use of `only()` w/ `--forbid-only` results in this error.
18152
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
18153
+ * and the Firebug extension (any Firefox version) are known
18154
+ * to support "%c" CSS customizations.
18155
+ *
18156
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
18012
18157
  */
18013
- FORBIDDEN_EXCLUSIVITY: 'ERR_MOCHA_FORBIDDEN_EXCLUSIVITY'
18014
- };
18015
- /**
18016
- * Creates an error object to be thrown when no files to be tested could be found using specified pattern.
18017
- *
18018
- * @public
18019
- * @param {string} message - Error message to be displayed.
18020
- * @param {string} pattern - User-specified argument value.
18021
- * @returns {Error} instance detailing the error condition
18022
- */
18023
-
18024
- function createNoFilesMatchPatternError(message, pattern) {
18025
- var err = new Error(message);
18026
- err.code = constants.NO_FILES_MATCH_PATTERN;
18027
- err.pattern = pattern;
18028
- return err;
18029
- }
18030
- /**
18031
- * Creates an error object to be thrown when the reporter specified in the options was not found.
18032
- *
18033
- * @public
18034
- * @param {string} message - Error message to be displayed.
18035
- * @param {string} reporter - User-specified reporter value.
18036
- * @returns {Error} instance detailing the error condition
18037
- */
18038
-
18039
-
18040
- function createInvalidReporterError(message, reporter) {
18041
- var err = new TypeError(message);
18042
- err.code = constants.INVALID_REPORTER;
18043
- err.reporter = reporter;
18044
- return err;
18045
- }
18046
- /**
18047
- * Creates an error object to be thrown when the interface specified in the options was not found.
18048
- *
18049
- * @public
18050
- * @param {string} message - Error message to be displayed.
18051
- * @param {string} ui - User-specified interface value.
18052
- * @returns {Error} instance detailing the error condition
18053
- */
18054
-
18055
-
18056
- function createInvalidInterfaceError(message, ui) {
18057
- var err = new Error(message);
18058
- err.code = constants.INVALID_INTERFACE;
18059
- err["interface"] = ui;
18060
- return err;
18061
- }
18062
- /**
18063
- * Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
18064
- *
18065
- * @public
18066
- * @param {string} message - Error message to be displayed.
18067
- * @returns {Error} instance detailing the error condition
18068
- */
18069
-
18070
-
18071
- function createUnsupportedError(message) {
18072
- var err = new Error(message);
18073
- err.code = constants.UNSUPPORTED;
18074
- return err;
18075
- }
18076
- /**
18077
- * Creates an error object to be thrown when an argument is missing.
18078
- *
18079
- * @public
18080
- * @param {string} message - Error message to be displayed.
18081
- * @param {string} argument - Argument name.
18082
- * @param {string} expected - Expected argument datatype.
18083
- * @returns {Error} instance detailing the error condition
18084
- */
18085
-
18086
-
18087
- function createMissingArgumentError(message, argument, expected) {
18088
- return createInvalidArgumentTypeError(message, argument, expected);
18089
- }
18090
- /**
18091
- * Creates an error object to be thrown when an argument did not use the supported type
18092
- *
18093
- * @public
18094
- * @param {string} message - Error message to be displayed.
18095
- * @param {string} argument - Argument name.
18096
- * @param {string} expected - Expected argument datatype.
18097
- * @returns {Error} instance detailing the error condition
18098
- */
18158
+ // eslint-disable-next-line complexity
18099
18159
 
18160
+ function useColors() {
18161
+ // NB: In an Electron preload script, document will be defined but not fully
18162
+ // initialized. Since we know we're in Chrome, we'll just detect this case
18163
+ // explicitly
18164
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
18165
+ return true;
18166
+ } // Internet Explorer and Edge do not support colors.
18100
18167
 
18101
- function createInvalidArgumentTypeError(message, argument, expected) {
18102
- var err = new TypeError(message);
18103
- err.code = constants.INVALID_ARG_TYPE;
18104
- err.argument = argument;
18105
- err.expected = expected;
18106
- err.actual = _typeof(argument);
18107
- return err;
18108
- }
18109
- /**
18110
- * Creates an error object to be thrown when an argument did not use the supported value
18111
- *
18112
- * @public
18113
- * @param {string} message - Error message to be displayed.
18114
- * @param {string} argument - Argument name.
18115
- * @param {string} value - Argument value.
18116
- * @param {string} [reason] - Why value is invalid.
18117
- * @returns {Error} instance detailing the error condition
18118
- */
18119
18168
 
18169
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
18170
+ return false;
18171
+ } // Is webkit? http://stackoverflow.com/a/16459606/376773
18172
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
18120
18173
 
18121
- function createInvalidArgumentValueError(message, argument, value, reason) {
18122
- var err = new TypeError(message);
18123
- err.code = constants.INVALID_ARG_VALUE;
18124
- err.argument = argument;
18125
- err.value = value;
18126
- err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
18127
- return err;
18128
- }
18129
- /**
18130
- * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
18131
- *
18132
- * @public
18133
- * @param {string} message - Error message to be displayed.
18134
- * @returns {Error} instance detailing the error condition
18135
- */
18136
18174
 
18175
+ return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
18176
+ typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
18177
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
18178
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
18179
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
18180
+ }
18181
+ /**
18182
+ * Colorize log arguments if enabled.
18183
+ *
18184
+ * @api public
18185
+ */
18137
18186
 
18138
- function createInvalidExceptionError(message, value) {
18139
- var err = new Error(message);
18140
- err.code = constants.INVALID_EXCEPTION;
18141
- err.valueType = _typeof(value);
18142
- err.value = value;
18143
- return err;
18144
- }
18145
- /**
18146
- * Creates an error object to be thrown when an unrecoverable error occurs.
18147
- *
18148
- * @public
18149
- * @param {string} message - Error message to be displayed.
18150
- * @returns {Error} instance detailing the error condition
18151
- */
18152
18187
 
18188
+ function formatArgs(args) {
18189
+ args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
18153
18190
 
18154
- function createFatalError(message, value) {
18155
- var err = new Error(message);
18156
- err.code = constants.FATAL;
18157
- err.valueType = _typeof(value);
18158
- err.value = value;
18159
- return err;
18160
- }
18161
- /**
18162
- * Dynamically creates a plugin-type-specific error based on plugin type
18163
- * @param {string} message - Error message
18164
- * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
18165
- * @param {string} [pluginId] - Name/path of plugin, if any
18166
- * @throws When `pluginType` is not known
18167
- * @public
18168
- * @returns {Error}
18169
- */
18191
+ if (!this.useColors) {
18192
+ return;
18193
+ }
18170
18194
 
18195
+ var c = 'color: ' + this.color;
18196
+ args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
18197
+ // arguments passed either before or after the %c, so we need to
18198
+ // figure out the correct index to insert the CSS into
18171
18199
 
18172
- function createInvalidPluginError(message, pluginType, pluginId) {
18173
- switch (pluginType) {
18174
- case 'reporter':
18175
- return createInvalidReporterError(message, pluginId);
18200
+ var index = 0;
18201
+ var lastC = 0;
18202
+ args[0].replace(/%[a-zA-Z%]/g, function (match) {
18203
+ if (match === '%%') {
18204
+ return;
18205
+ }
18176
18206
 
18177
- case 'interface':
18178
- return createInvalidInterfaceError(message, pluginId);
18207
+ index++;
18179
18208
 
18180
- default:
18181
- throw new Error('unknown pluginType "' + pluginType + '"');
18209
+ if (match === '%c') {
18210
+ // We only are interested in the *last* %c
18211
+ // (the user may have provided their own)
18212
+ lastC = index;
18213
+ }
18214
+ });
18215
+ args.splice(lastC, 0, c);
18182
18216
  }
18183
- }
18184
- /**
18185
- * Creates an error object to be thrown when a mocha object's `run` method is executed while it is already disposed.
18186
- * @param {string} message The error message to be displayed.
18187
- * @param {boolean} cleanReferencesAfterRun the value of `cleanReferencesAfterRun`
18188
- * @param {Mocha} instance the mocha instance that throw this error
18189
- */
18217
+ /**
18218
+ * Invokes `console.log()` when available.
18219
+ * No-op when `console.log` is not a "function".
18220
+ *
18221
+ * @api public
18222
+ */
18190
18223
 
18191
18224
 
18192
- function createMochaInstanceAlreadyDisposedError(message, cleanReferencesAfterRun, instance) {
18193
- var err = new Error(message);
18194
- err.code = constants.INSTANCE_ALREADY_DISPOSED;
18195
- err.cleanReferencesAfterRun = cleanReferencesAfterRun;
18196
- err.instance = instance;
18197
- return err;
18198
- }
18199
- /**
18200
- * Creates an error object to be thrown when a mocha object's `run` method is called while a test run is in progress.
18201
- * @param {string} message The error message to be displayed.
18202
- */
18225
+ function log() {
18226
+ var _console;
18203
18227
 
18228
+ // This hackery is required for IE8/9, where
18229
+ // the `console.log` function doesn't have 'apply'
18230
+ return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
18231
+ }
18232
+ /**
18233
+ * Save `namespaces`.
18234
+ *
18235
+ * @param {String} namespaces
18236
+ * @api private
18237
+ */
18204
18238
 
18205
- function createMochaInstanceAlreadyRunningError(message, instance) {
18206
- var err = new Error(message);
18207
- err.code = constants.INSTANCE_ALREADY_RUNNING;
18208
- err.instance = instance;
18209
- return err;
18210
- }
18211
- /*
18212
- * Creates an error object to be thrown when done() is called multiple times in a test
18213
- *
18214
- * @public
18215
- * @param {Runnable} runnable - Original runnable
18216
- * @param {Error} [originalErr] - Original error, if any
18217
- * @returns {Error} instance detailing the error condition
18218
- */
18219
18239
 
18240
+ function save(namespaces) {
18241
+ try {
18242
+ if (namespaces) {
18243
+ exports.storage.setItem('debug', namespaces);
18244
+ } else {
18245
+ exports.storage.removeItem('debug');
18246
+ }
18247
+ } catch (error) {// Swallow
18248
+ // XXX (@Qix-) should we be logging these?
18249
+ }
18250
+ }
18251
+ /**
18252
+ * Load `namespaces`.
18253
+ *
18254
+ * @return {String} returns the previously persisted debug modes
18255
+ * @api private
18256
+ */
18220
18257
 
18221
- function createMultipleDoneError(runnable, originalErr) {
18222
- var title;
18223
18258
 
18224
- try {
18225
- title = format$1('<%s>', runnable.fullTitle());
18259
+ function load() {
18260
+ var r;
18226
18261
 
18227
- if (runnable.parent.root) {
18228
- title += ' (of root suite)';
18229
- }
18230
- } catch (ignored) {
18231
- title = format$1('<%s> (of unknown suite)', runnable.title);
18232
- }
18262
+ try {
18263
+ r = exports.storage.getItem('debug');
18264
+ } catch (error) {// Swallow
18265
+ // XXX (@Qix-) should we be logging these?
18266
+ } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
18233
18267
 
18234
- var message = format$1('done() called multiple times in %s %s', runnable.type ? runnable.type : 'unknown runnable', title);
18235
18268
 
18236
- if (runnable.file) {
18237
- message += format$1(' of file %s', runnable.file);
18238
- }
18269
+ if (!r && typeof process$1 !== 'undefined' && 'env' in process$1) {
18270
+ r = process$1.env.DEBUG;
18271
+ }
18239
18272
 
18240
- if (originalErr) {
18241
- message += format$1('; in addition, done() received error: %s', originalErr);
18273
+ return r;
18242
18274
  }
18275
+ /**
18276
+ * Localstorage attempts to return the localstorage.
18277
+ *
18278
+ * This is necessary because safari throws
18279
+ * when a user disables cookies/localstorage
18280
+ * and you attempt to access it.
18281
+ *
18282
+ * @return {LocalStorage}
18283
+ * @api private
18284
+ */
18243
18285
 
18244
- var err = new Error(message);
18245
- err.code = constants.MULTIPLE_DONE;
18246
- err.valueType = _typeof(originalErr);
18247
- err.value = originalErr;
18248
- return err;
18249
- }
18250
- /**
18251
- * Creates an error object to be thrown when `.only()` is used with
18252
- * `--forbid-only`.
18253
- * @public
18254
- * @param {Mocha} mocha - Mocha instance
18255
- * @returns {Error} Error with code {@link constants.FORBIDDEN_EXCLUSIVITY}
18256
- */
18257
18286
 
18287
+ function localstorage() {
18288
+ try {
18289
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
18290
+ // The Browser also has localStorage in the global context.
18291
+ return localStorage;
18292
+ } catch (error) {// Swallow
18293
+ // XXX (@Qix-) should we be logging these?
18294
+ }
18295
+ }
18258
18296
 
18259
- function createForbiddenExclusivityError(mocha) {
18260
- var err = new Error(mocha.isWorker ? '`.only` is not supported in parallel mode' : '`.only` forbidden by --forbid-only');
18261
- err.code = constants.FORBIDDEN_EXCLUSIVITY;
18262
- return err;
18263
- }
18297
+ module.exports = common(exports);
18298
+ var formatters = module.exports.formatters;
18299
+ /**
18300
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
18301
+ */
18264
18302
 
18265
- var errors = {
18266
- createInvalidArgumentTypeError: createInvalidArgumentTypeError,
18267
- createInvalidArgumentValueError: createInvalidArgumentValueError,
18268
- createInvalidExceptionError: createInvalidExceptionError,
18269
- createInvalidInterfaceError: createInvalidInterfaceError,
18270
- createInvalidReporterError: createInvalidReporterError,
18271
- createMissingArgumentError: createMissingArgumentError,
18272
- createNoFilesMatchPatternError: createNoFilesMatchPatternError,
18273
- createUnsupportedError: createUnsupportedError,
18274
- createInvalidPluginError: createInvalidPluginError,
18275
- createMochaInstanceAlreadyDisposedError: createMochaInstanceAlreadyDisposedError,
18276
- createMochaInstanceAlreadyRunningError: createMochaInstanceAlreadyRunningError,
18277
- createFatalError: createFatalError,
18278
- createMultipleDoneError: createMultipleDoneError,
18279
- createForbiddenExclusivityError: createForbiddenExclusivityError,
18280
- constants: constants
18281
- };
18303
+ formatters.j = function (v) {
18304
+ try {
18305
+ return JSON.stringify(v);
18306
+ } catch (error) {
18307
+ return '[UnexpectedJSONParseError]: ' + error.message;
18308
+ }
18309
+ };
18310
+ });
18282
18311
 
18283
18312
  var EventEmitter$1 = EventEmitter.EventEmitter;
18284
18313
  var debug$1 = browser$2('mocha:runnable');
@@ -20738,8 +20767,6 @@
20738
20767
 
20739
20768
  Runner.constants = constants$2;
20740
20769
 
20741
- var require$$9 = getCjsExportFromNamespace(_nodeResolve_empty$1);
20742
-
20743
20770
  var base = createCommonjsModule(function (module, exports) {
20744
20771
  /**
20745
20772
  * @module Base
@@ -20782,7 +20809,7 @@
20782
20809
  * Enable coloring by default, except in the browser interface.
20783
20810
  */
20784
20811
 
20785
- exports.useColors = !isBrowser && (require$$9.stdout || process$1.env.MOCHA_COLORS !== undefined);
20812
+ exports.useColors = !isBrowser && (require$$11.stdout || process$1.env.MOCHA_COLORS !== undefined);
20786
20813
  /**
20787
20814
  * Inline diffs instead of +/-
20788
20815
  */
@@ -23541,7 +23568,7 @@
23541
23568
  });
23542
23569
 
23543
23570
  var name = "mocha";
23544
- var version$2 = "8.1.2";
23571
+ var version$2 = "8.1.3";
23545
23572
  var homepage = "https://mochajs.org/";
23546
23573
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
23547
23574
  var _package = {
@@ -23560,7 +23587,7 @@
23560
23587
  'default': _package
23561
23588
  });
23562
23589
 
23563
- var require$$8 = getCjsExportFromNamespace(_package$1);
23590
+ var require$$10 = getCjsExportFromNamespace(_package$1);
23564
23591
 
23565
23592
  /**
23566
23593
  * Web Notifications module.
@@ -23690,7 +23717,7 @@
23690
23717
  cross: "\u274C",
23691
23718
  tick: "\u2705"
23692
23719
  };
23693
- var logo = require$$8.notifyLogo;
23720
+ var logo = require$$10.notifyLogo;
23694
23721
 
23695
23722
  var _message;
23696
23723
 
@@ -24647,11 +24674,12 @@
24647
24674
  * MIT Licensed
24648
24675
  */
24649
24676
 
24650
- var esmUtils = utils.supportsEsModules(true) ? require$$9 : undefined;
24651
- var createInvalidReporterError = errors.createInvalidReporterError;
24652
- var createInvalidInterfaceError = errors.createInvalidInterfaceError;
24653
- var createMochaInstanceAlreadyDisposedError = errors.createMochaInstanceAlreadyDisposedError;
24654
- var createMochaInstanceAlreadyRunningError = errors.createMochaInstanceAlreadyRunningError;
24677
+ var esmUtils = utils.supportsEsModules(true) ? require$$11 : undefined;
24678
+ var createUnsupportedError = errors.createUnsupportedError,
24679
+ createInvalidInterfaceError = errors.createInvalidInterfaceError,
24680
+ createInvalidReporterError = errors.createInvalidReporterError,
24681
+ createMochaInstanceAlreadyDisposedError = errors.createMochaInstanceAlreadyDisposedError,
24682
+ createMochaInstanceAlreadyRunningError = errors.createMochaInstanceAlreadyRunningError;
24655
24683
  var EVENT_FILE_PRE_REQUIRE = suite.constants.EVENT_FILE_PRE_REQUIRE;
24656
24684
  var EVENT_FILE_POST_REQUIRE = suite.constants.EVENT_FILE_POST_REQUIRE;
24657
24685
  var EVENT_FILE_REQUIRE = suite.constants.EVENT_FILE_REQUIRE;
@@ -25041,7 +25069,11 @@
25041
25069
 
25042
25070
 
25043
25071
  Mocha.unloadFile = function (file) {
25044
- delete require.cache[require.resolve(file)];
25072
+ if (utils.isBrowser()) {
25073
+ throw createUnsupportedError('unloadFile() is only suported in a Node.js environment');
25074
+ }
25075
+
25076
+ return require$$11.unloadFile(file);
25045
25077
  };
25046
25078
  /**
25047
25079
  * Unloads `files` from Node's `require` cache.
@@ -25523,7 +25555,7 @@
25523
25555
 
25524
25556
 
25525
25557
  Object.defineProperty(Mocha.prototype, 'version', {
25526
- value: require$$8.version,
25558
+ value: require$$10.version,
25527
25559
  configurable: false,
25528
25560
  enumerable: true,
25529
25561
  writable: false
@@ -25675,7 +25707,7 @@
25675
25707
 
25676
25708
  Mocha.prototype.parallelMode = function parallelMode(enable) {
25677
25709
  if (utils.isBrowser()) {
25678
- throw errors.createUnsupportedError('parallel mode is only supported in Node.js');
25710
+ throw createUnsupportedError('parallel mode is only supported in Node.js');
25679
25711
  }
25680
25712
 
25681
25713
  var parallel = enable === true;
@@ -25685,12 +25717,12 @@
25685
25717
  }
25686
25718
 
25687
25719
  if (this._state !== mochaStates.INIT) {
25688
- throw errors.createUnsupportedError('cannot change parallel mode after having called run()');
25720
+ throw createUnsupportedError('cannot change parallel mode after having called run()');
25689
25721
  }
25690
25722
 
25691
25723
  this.options.parallel = parallel; // swap Runner class
25692
25724
 
25693
- this._runnerClass = parallel ? require$$9 : exports.Runner; // lazyLoadFiles may have been set `true` otherwise (for ESM loading),
25725
+ this._runnerClass = parallel ? require$$11 : exports.Runner; // lazyLoadFiles may have been set `true` otherwise (for ESM loading),
25694
25726
  // so keep `true` if so.
25695
25727
 
25696
25728
  return this.lazyLoadFiles(this._lazyLoadFiles || parallel);