mocha 9.0.1 → 9.1.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/mocha-es2018.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@9.0.1 in javascript ES2018
1
+ // mocha@9.1.1 in javascript ES2018
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -146,38 +146,38 @@
146
146
  Item$1.prototype.run = function () {
147
147
  this.fun.apply(null, this.array);
148
148
  };
149
- var title = 'browser';
150
- var platform = 'browser';
151
- var browser$3 = true;
152
- var env = {};
153
- var argv = [];
154
- var version$1 = ''; // empty string to avoid regexp issues
155
- var versions = {};
156
- var release = {};
157
- var config = {};
158
-
159
- function noop() {}
160
-
161
- var on = noop;
162
- var addListener = noop;
163
- var once = noop;
164
- var off = noop;
165
- var removeListener = noop;
166
- var removeAllListeners = noop;
167
- var emit = noop;
168
-
169
- function binding(name) {
149
+ var title$1 = 'browser';
150
+ var platform$1 = 'browser';
151
+ var browser$4 = true;
152
+ var env$1 = {};
153
+ var argv$1 = [];
154
+ var version$2 = ''; // empty string to avoid regexp issues
155
+ var versions$1 = {};
156
+ var release$1 = {};
157
+ var config$1 = {};
158
+
159
+ function noop$1() {}
160
+
161
+ var on$1 = noop$1;
162
+ var addListener$1 = noop$1;
163
+ var once$1 = noop$1;
164
+ var off$1 = noop$1;
165
+ var removeListener$1 = noop$1;
166
+ var removeAllListeners$1 = noop$1;
167
+ var emit$1 = noop$1;
168
+
169
+ function binding$1(name) {
170
170
  throw new Error('process.binding is not supported');
171
171
  }
172
172
 
173
- function cwd () { return '/' }
174
- function chdir (dir) {
173
+ function cwd$1 () { return '/' }
174
+ function chdir$1 (dir) {
175
175
  throw new Error('process.chdir is not supported');
176
- }function umask() { return 0; }
176
+ }function umask$1() { return 0; }
177
177
 
178
178
  // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
179
179
  var performance$1 = global$1.performance || {};
180
- var performanceNow =
180
+ var performanceNow$1 =
181
181
  performance$1.now ||
182
182
  performance$1.mozNow ||
183
183
  performance$1.msNow ||
@@ -187,8 +187,8 @@
187
187
 
188
188
  // generate timestamp or delta
189
189
  // see http://nodejs.org/api/process.html#process_process_hrtime
190
- function hrtime(previousTimestamp){
191
- var clocktime = performanceNow.call(performance$1)*1e-3;
190
+ function hrtime$1(previousTimestamp){
191
+ var clocktime = performanceNow$1.call(performance$1)*1e-3;
192
192
  var seconds = Math.floor(clocktime);
193
193
  var nanoseconds = Math.floor((clocktime%1)*1e9);
194
194
  if (previousTimestamp) {
@@ -202,37 +202,37 @@
202
202
  return [seconds,nanoseconds]
203
203
  }
204
204
 
205
- var startTime = new Date();
206
- function uptime() {
205
+ var startTime$1 = new Date();
206
+ function uptime$1() {
207
207
  var currentTime = new Date();
208
- var dif = currentTime - startTime;
208
+ var dif = currentTime - startTime$1;
209
209
  return dif / 1000;
210
210
  }
211
211
 
212
- var process = {
212
+ var process$1 = {
213
213
  nextTick: nextTick$1,
214
- title: title,
215
- browser: browser$3,
216
- env: env,
217
- argv: argv,
218
- version: version$1,
219
- versions: versions,
220
- on: on,
221
- addListener: addListener,
222
- once: once,
223
- off: off,
224
- removeListener: removeListener,
225
- removeAllListeners: removeAllListeners,
226
- emit: emit,
227
- binding: binding,
228
- cwd: cwd,
229
- chdir: chdir,
230
- umask: umask,
231
- hrtime: hrtime,
232
- platform: platform,
233
- release: release,
234
- config: config,
235
- uptime: uptime
214
+ title: title$1,
215
+ browser: browser$4,
216
+ env: env$1,
217
+ argv: argv$1,
218
+ version: version$2,
219
+ versions: versions$1,
220
+ on: on$1,
221
+ addListener: addListener$1,
222
+ once: once$1,
223
+ off: off$1,
224
+ removeListener: removeListener$1,
225
+ removeAllListeners: removeAllListeners$1,
226
+ emit: emit$1,
227
+ binding: binding$1,
228
+ cwd: cwd$1,
229
+ chdir: chdir$1,
230
+ umask: umask$1,
231
+ hrtime: hrtime$1,
232
+ platform: platform$1,
233
+ release: release$1,
234
+ config: config$1,
235
+ uptime: uptime$1
236
236
  };
237
237
 
238
238
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -2815,16 +2815,97 @@
2815
2815
  Item.prototype.run = function () {
2816
2816
  this.fun.apply(null, this.array);
2817
2817
  };
2818
+ var title = 'browser';
2819
+ var platform = 'browser';
2820
+ var browser$3 = true;
2821
+ var env = {};
2822
+ var argv = [];
2823
+ var version$1 = ''; // empty string to avoid regexp issues
2824
+ var versions = {};
2825
+ var release = {};
2826
+ var config = {};
2827
+
2828
+ function noop() {}
2829
+
2830
+ var on = noop;
2831
+ var addListener = noop;
2832
+ var once = noop;
2833
+ var off = noop;
2834
+ var removeListener = noop;
2835
+ var removeAllListeners = noop;
2836
+ var emit = noop;
2837
+
2838
+ function binding(name) {
2839
+ throw new Error('process.binding is not supported');
2840
+ }
2841
+
2842
+ function cwd () { return '/' }
2843
+ function chdir (dir) {
2844
+ throw new Error('process.chdir is not supported');
2845
+ }function umask() { return 0; }
2818
2846
 
2819
2847
  // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
2820
2848
  var performance = global$1.performance || {};
2821
- performance.now ||
2849
+ var performanceNow =
2850
+ performance.now ||
2822
2851
  performance.mozNow ||
2823
2852
  performance.msNow ||
2824
2853
  performance.oNow ||
2825
2854
  performance.webkitNow ||
2826
2855
  function(){ return (new Date()).getTime() };
2827
2856
 
2857
+ // generate timestamp or delta
2858
+ // see http://nodejs.org/api/process.html#process_process_hrtime
2859
+ function hrtime(previousTimestamp){
2860
+ var clocktime = performanceNow.call(performance)*1e-3;
2861
+ var seconds = Math.floor(clocktime);
2862
+ var nanoseconds = Math.floor((clocktime%1)*1e9);
2863
+ if (previousTimestamp) {
2864
+ seconds = seconds - previousTimestamp[0];
2865
+ nanoseconds = nanoseconds - previousTimestamp[1];
2866
+ if (nanoseconds<0) {
2867
+ seconds--;
2868
+ nanoseconds += 1e9;
2869
+ }
2870
+ }
2871
+ return [seconds,nanoseconds]
2872
+ }
2873
+
2874
+ var startTime = new Date();
2875
+ function uptime() {
2876
+ var currentTime = new Date();
2877
+ var dif = currentTime - startTime;
2878
+ return dif / 1000;
2879
+ }
2880
+
2881
+ var browser$1$1 = {
2882
+ nextTick: nextTick,
2883
+ title: title,
2884
+ browser: browser$3,
2885
+ env: env,
2886
+ argv: argv,
2887
+ version: version$1,
2888
+ versions: versions,
2889
+ on: on,
2890
+ addListener: addListener,
2891
+ once: once,
2892
+ off: off,
2893
+ removeListener: removeListener,
2894
+ removeAllListeners: removeAllListeners,
2895
+ emit: emit,
2896
+ binding: binding,
2897
+ cwd: cwd,
2898
+ chdir: chdir,
2899
+ umask: umask,
2900
+ hrtime: hrtime,
2901
+ platform: platform,
2902
+ release: release,
2903
+ config: config,
2904
+ uptime: uptime
2905
+ };
2906
+
2907
+ var process = browser$1$1;
2908
+
2828
2909
  var inherits$2;
2829
2910
  if (typeof Object.create === 'function'){
2830
2911
  inherits$2 = function inherits(ctor, superCtor) {
@@ -2900,10 +2981,18 @@
2900
2981
  };
2901
2982
  }
2902
2983
 
2984
+ if (process.noDeprecation === true) {
2985
+ return fn;
2986
+ }
2987
+
2903
2988
  var warned = false;
2904
2989
  function deprecated() {
2905
2990
  if (!warned) {
2906
- {
2991
+ if (process.throwDeprecation) {
2992
+ throw new Error(msg);
2993
+ } else if (process.traceDeprecation) {
2994
+ console.trace(msg);
2995
+ } else {
2907
2996
  console.error(msg);
2908
2997
  }
2909
2998
  warned = true;
@@ -2918,7 +3007,7 @@
2918
3007
  var debugEnviron;
2919
3008
  function debuglog(set) {
2920
3009
  if (isUndefined(debugEnviron))
2921
- debugEnviron = '';
3010
+ debugEnviron = process.env.NODE_DEBUG || '';
2922
3011
  set = set.toUpperCase();
2923
3012
  if (!debugs[set]) {
2924
3013
  if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
@@ -10290,8 +10379,8 @@
10290
10379
  * @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatible with Mocha
10291
10380
  */
10292
10381
  exports.supportsEsModules = function(partialSupport) {
10293
- if (!exports.isBrowser() && process.versions && process.versions.node) {
10294
- var versionFields = process.versions.node.split('.');
10382
+ if (!exports.isBrowser() && process$1.versions && process$1.versions.node) {
10383
+ var versionFields = process$1.versions.node.split('.');
10295
10384
  var major = +versionFields[0];
10296
10385
  var minor = +versionFields[1];
10297
10386
 
@@ -10310,7 +10399,7 @@
10310
10399
  * @private
10311
10400
  */
10312
10401
  exports.cwd = function cwd() {
10313
- return process.cwd();
10402
+ return process$1.cwd();
10314
10403
  };
10315
10404
 
10316
10405
  /**
@@ -11058,8 +11147,8 @@
11058
11147
  }
11059
11148
 
11060
11149
  // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
11061
- if (!r && typeof process !== 'undefined' && 'env' in process) {
11062
- r = process.env.DEBUG;
11150
+ if (!r && typeof process$1 !== 'undefined' && 'env' in process$1) {
11151
+ r = process$1.env.DEBUG;
11063
11152
  }
11064
11153
 
11065
11154
  return r;
@@ -11118,8 +11207,8 @@
11118
11207
  * @ignore
11119
11208
  */
11120
11209
  const emitWarning = (msg, type) => {
11121
- if (process.emitWarning) {
11122
- process.emitWarning(msg, type);
11210
+ if (process$1.emitWarning) {
11211
+ process$1.emitWarning(msg, type);
11123
11212
  } else {
11124
11213
  /* istanbul ignore next */
11125
11214
  nextTick$1(function() {
@@ -11432,7 +11521,7 @@
11432
11521
  /**
11433
11522
  * Dynamically creates a plugin-type-specific error based on plugin type
11434
11523
  * @param {string} message - Error message
11435
- * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
11524
+ * @param {"reporter"|"ui"} pluginType - Plugin type. Future: expand as needed
11436
11525
  * @param {string} [pluginId] - Name/path of plugin, if any
11437
11526
  * @throws When `pluginType` is not known
11438
11527
  * @public
@@ -11443,7 +11532,7 @@
11443
11532
  switch (pluginType) {
11444
11533
  case 'reporter':
11445
11534
  return createInvalidReporterError(message, pluginId);
11446
- case 'interface':
11535
+ case 'ui':
11447
11536
  return createInvalidInterfaceError(message, pluginId);
11448
11537
  default:
11449
11538
  throw new Error('unknown pluginType "' + pluginType + '"');
@@ -12193,7 +12282,9 @@
12193
12282
  */
12194
12283
  Hook.prototype.serialize = function serialize() {
12195
12284
  return {
12196
- $$isPending: this.isPending(),
12285
+ $$currentRetry: this.currentRetry(),
12286
+ $$fullTitle: this.fullTitle(),
12287
+ $$isPending: Boolean(this.isPending()),
12197
12288
  $$titlePath: this.titlePath(),
12198
12289
  ctx:
12199
12290
  this.ctx && this.ctx.currentTest
@@ -12204,9 +12295,13 @@
12204
12295
  }
12205
12296
  }
12206
12297
  : {},
12298
+ duration: this.duration,
12299
+ file: this.file,
12207
12300
  parent: {
12301
+ $$fullTitle: this.parent.fullTitle(),
12208
12302
  [MOCHA_ID_PROP_NAME$1]: this.parent.id
12209
12303
  },
12304
+ state: this.state,
12210
12305
  title: this.title,
12211
12306
  type: this.type,
12212
12307
  [MOCHA_ID_PROP_NAME$1]: this.id
@@ -12809,10 +12904,10 @@
12809
12904
  return {
12810
12905
  _bail: this._bail,
12811
12906
  $$fullTitle: this.fullTitle(),
12812
- $$isPending: this.isPending(),
12907
+ $$isPending: Boolean(this.isPending()),
12813
12908
  root: this.root,
12814
12909
  title: this.title,
12815
- id: this.id,
12910
+ [MOCHA_ID_PROP_NAME]: this.id,
12816
12911
  parent: this.parent ? {[MOCHA_ID_PROP_NAME]: this.parent.id} : null
12817
12912
  };
12818
12913
  };
@@ -13045,10 +13140,11 @@
13045
13140
  * @public
13046
13141
  * @class
13047
13142
  * @param {Suite} suite - Root suite
13048
- * @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether or not to delay execution of root suite until ready.
13143
+ * @param {Object|boolean} [opts] - Options. If `boolean` (deprecated), whether to delay execution of root suite until ready.
13144
+ * @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
13049
13145
  * @param {boolean} [opts.delay] - Whether to delay execution of root suite until ready.
13050
13146
  * @param {boolean} [opts.dryRun] - Whether to report tests without running them.
13051
- * @param {boolean} [opts.cleanReferencesAfterRun] - Whether to clean references to test fns and hooks when a suite is done.
13147
+ * @param {boolean} [options.failZero] - Whether to fail test run if zero tests encountered.
13052
13148
  */
13053
13149
  constructor(suite, opts) {
13054
13150
  super();
@@ -13105,14 +13201,14 @@
13105
13201
  'trapped unhandled rejection from (probably) user code; re-emitting on process'
13106
13202
  );
13107
13203
  this._removeEventListener(
13108
- process,
13204
+ process$1,
13109
13205
  'unhandledRejection',
13110
13206
  this.unhandled
13111
13207
  );
13112
13208
  try {
13113
- process.emit('unhandledRejection', reason, promise);
13209
+ process$1.emit('unhandledRejection', reason, promise);
13114
13210
  } finally {
13115
- this._addEventListener(process, 'unhandledRejection', this.unhandled);
13211
+ this._addEventListener(process$1, 'unhandledRejection', this.unhandled);
13116
13212
  }
13117
13213
  }
13118
13214
  };
@@ -13954,6 +14050,8 @@
13954
14050
  fn = fn || function() {};
13955
14051
 
13956
14052
  const end = () => {
14053
+ if (!this.total && this._opts.failZero) this.failures = 1;
14054
+
13957
14055
  debug('run(): root suite completed; emitting %s', constants$1.EVENT_RUN_END);
13958
14056
  this.emit(constants$1.EVENT_RUN_END);
13959
14057
  };
@@ -13996,10 +14094,10 @@
13996
14094
  fn(this.failures);
13997
14095
  });
13998
14096
 
13999
- this._removeEventListener(process, 'uncaughtException', this.uncaught);
14000
- this._removeEventListener(process, 'unhandledRejection', this.unhandled);
14001
- this._addEventListener(process, 'uncaughtException', this.uncaught);
14002
- this._addEventListener(process, 'unhandledRejection', this.unhandled);
14097
+ this._removeEventListener(process$1, 'uncaughtException', this.uncaught);
14098
+ this._removeEventListener(process$1, 'unhandledRejection', this.unhandled);
14099
+ this._addEventListener(process$1, 'uncaughtException', this.uncaught);
14100
+ this._addEventListener(process$1, 'unhandledRejection', this.unhandled);
14003
14101
 
14004
14102
  if (this._delay) {
14005
14103
  // for reporters, I guess.
@@ -14214,7 +14312,7 @@
14214
14312
  * Check if both stdio streams are associated with a tty.
14215
14313
  */
14216
14314
 
14217
- var isatty = isBrowser || (process.stdout.isTTY && process.stderr.isTTY);
14315
+ var isatty = isBrowser || (process$1.stdout.isTTY && process$1.stderr.isTTY);
14218
14316
 
14219
14317
  /**
14220
14318
  * Save log references to avoid tests interfering (see GH-3604).
@@ -14227,7 +14325,7 @@
14227
14325
 
14228
14326
  exports.useColors =
14229
14327
  !isBrowser &&
14230
- (require$$11.stdout || process.env.MOCHA_COLORS !== undefined);
14328
+ (require$$11.stdout || process$1.env.MOCHA_COLORS !== undefined);
14231
14329
 
14232
14330
  /**
14233
14331
  * Inline diffs instead of +/-
@@ -14269,7 +14367,7 @@
14269
14367
 
14270
14368
  exports.symbols = {
14271
14369
  ok: browser$1.success,
14272
- err: browser$1.err,
14370
+ err: browser$1.error,
14273
14371
  dot: '.',
14274
14372
  comma: ',',
14275
14373
  bang: '!'
@@ -14305,7 +14403,7 @@
14305
14403
  if (isBrowser) {
14306
14404
  exports.window.width = getBrowserWindowSize()[1];
14307
14405
  } else {
14308
- exports.window.width = process.stdout.getWindowSize(1)[0];
14406
+ exports.window.width = process$1.stdout.getWindowSize(1)[0];
14309
14407
  }
14310
14408
  }
14311
14409
 
@@ -14315,19 +14413,19 @@
14315
14413
 
14316
14414
  exports.cursor = {
14317
14415
  hide: function() {
14318
- isatty && process.stdout.write('\u001b[?25l');
14416
+ isatty && process$1.stdout.write('\u001b[?25l');
14319
14417
  },
14320
14418
 
14321
14419
  show: function() {
14322
- isatty && process.stdout.write('\u001b[?25h');
14420
+ isatty && process$1.stdout.write('\u001b[?25h');
14323
14421
  },
14324
14422
 
14325
14423
  deleteLine: function() {
14326
- isatty && process.stdout.write('\u001b[2K');
14424
+ isatty && process$1.stdout.write('\u001b[2K');
14327
14425
  },
14328
14426
 
14329
14427
  beginningOfLine: function() {
14330
- isatty && process.stdout.write('\u001b[0G');
14428
+ isatty && process$1.stdout.write('\u001b[0G');
14331
14429
  },
14332
14430
 
14333
14431
  CR: function() {
@@ -14335,7 +14433,7 @@
14335
14433
  exports.cursor.deleteLine();
14336
14434
  exports.cursor.beginningOfLine();
14337
14435
  } else {
14338
- process.stdout.write('\r');
14436
+ process$1.stdout.write('\r');
14339
14437
  }
14340
14438
  }
14341
14439
  };
@@ -14757,36 +14855,36 @@
14757
14855
  var n = -1;
14758
14856
 
14759
14857
  runner.on(EVENT_RUN_BEGIN, function() {
14760
- process.stdout.write('\n');
14858
+ process$1.stdout.write('\n');
14761
14859
  });
14762
14860
 
14763
14861
  runner.on(EVENT_TEST_PENDING, function() {
14764
14862
  if (++n % width === 0) {
14765
- process.stdout.write('\n ');
14863
+ process$1.stdout.write('\n ');
14766
14864
  }
14767
- process.stdout.write(base.color('pending', base.symbols.comma));
14865
+ process$1.stdout.write(base.color('pending', base.symbols.comma));
14768
14866
  });
14769
14867
 
14770
14868
  runner.on(EVENT_TEST_PASS, function(test) {
14771
14869
  if (++n % width === 0) {
14772
- process.stdout.write('\n ');
14870
+ process$1.stdout.write('\n ');
14773
14871
  }
14774
14872
  if (test.speed === 'slow') {
14775
- process.stdout.write(base.color('bright yellow', base.symbols.dot));
14873
+ process$1.stdout.write(base.color('bright yellow', base.symbols.dot));
14776
14874
  } else {
14777
- process.stdout.write(base.color(test.speed, base.symbols.dot));
14875
+ process$1.stdout.write(base.color(test.speed, base.symbols.dot));
14778
14876
  }
14779
14877
  });
14780
14878
 
14781
14879
  runner.on(EVENT_TEST_FAIL, function() {
14782
14880
  if (++n % width === 0) {
14783
- process.stdout.write('\n ');
14881
+ process$1.stdout.write('\n ');
14784
14882
  }
14785
- process.stdout.write(base.color('fail', base.symbols.bang));
14883
+ process$1.stdout.write(base.color('fail', base.symbols.bang));
14786
14884
  });
14787
14885
 
14788
14886
  runner.once(EVENT_RUN_END, function() {
14789
- process.stdout.write('\n');
14887
+ process$1.stdout.write('\n');
14790
14888
  self.epilogue();
14791
14889
  });
14792
14890
  }
@@ -14998,7 +15096,7 @@
14998
15096
  function println(format, varArgs) {
14999
15097
  var vargs = Array.from(arguments);
15000
15098
  vargs[0] += '\n';
15001
- process.stdout.write(sprintf.apply(null, vargs));
15099
+ process$1.stdout.write(sprintf.apply(null, vargs));
15002
15100
  }
15003
15101
 
15004
15102
  /**
@@ -15191,6 +15289,8 @@
15191
15289
  TAP.description = 'TAP-compatible output';
15192
15290
  });
15193
15291
 
15292
+ var fs = {};
15293
+
15194
15294
  var json = createCommonjsModule(function (module, exports) {
15195
15295
  /**
15196
15296
  * @module JSON
@@ -15200,12 +15300,16 @@
15200
15300
  */
15201
15301
 
15202
15302
 
15303
+
15304
+
15305
+ const createUnsupportedError = errors.createUnsupportedError;
15306
+
15203
15307
  var constants = runner.constants;
15204
15308
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
15309
+ var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
15205
15310
  var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
15206
15311
  var EVENT_TEST_END = constants.EVENT_TEST_END;
15207
15312
  var EVENT_RUN_END = constants.EVENT_RUN_END;
15208
- var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
15209
15313
 
15210
15314
  /**
15211
15315
  * Expose `JSON`.
@@ -15223,7 +15327,7 @@
15223
15327
  * @param {Runner} runner - Instance triggers reporter actions.
15224
15328
  * @param {Object} [options] - runner options
15225
15329
  */
15226
- function JSONReporter(runner, options) {
15330
+ function JSONReporter(runner, options = {}) {
15227
15331
  base.call(this, runner, options);
15228
15332
 
15229
15333
  var self = this;
@@ -15231,6 +15335,14 @@
15231
15335
  var pending = [];
15232
15336
  var failures = [];
15233
15337
  var passes = [];
15338
+ var output;
15339
+
15340
+ if (options.reporterOption && options.reporterOption.output) {
15341
+ if (utils.isBrowser()) {
15342
+ throw createUnsupportedError('file output not supported in browser');
15343
+ }
15344
+ output = options.reporterOption.output;
15345
+ }
15234
15346
 
15235
15347
  runner.on(EVENT_TEST_END, function(test) {
15236
15348
  tests.push(test);
@@ -15259,7 +15371,20 @@
15259
15371
 
15260
15372
  runner.testResults = obj;
15261
15373
 
15262
- process.stdout.write(JSON.stringify(obj, null, 2));
15374
+ var json = JSON.stringify(obj, null, 2);
15375
+ if (output) {
15376
+ try {
15377
+ fs.mkdirSync(path.dirname(output), {recursive: true});
15378
+ fs.writeFileSync(output, json);
15379
+ } catch (err) {
15380
+ console.error(
15381
+ `${base.symbols.err} [mocha] writing output to "${output}" failed: ${err.message}\n`
15382
+ );
15383
+ process$1.stdout.write(json);
15384
+ }
15385
+ } else {
15386
+ process$1.stdout.write(json);
15387
+ }
15263
15388
  });
15264
15389
  }
15265
15390
 
@@ -15891,7 +16016,7 @@
15891
16016
  });
15892
16017
 
15893
16018
  runner.on(EVENT_TEST_BEGIN, function(test) {
15894
- process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
16019
+ process$1.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
15895
16020
  });
15896
16021
 
15897
16022
  runner.on(EVENT_TEST_PENDING, function(test) {
@@ -15962,9 +16087,9 @@
15962
16087
 
15963
16088
  runner.on(EVENT_RUN_BEGIN, function() {
15964
16089
  // clear screen
15965
- process.stdout.write('\u001b[2J');
16090
+ process$1.stdout.write('\u001b[2J');
15966
16091
  // set cursor position
15967
- process.stdout.write('\u001b[1;3H');
16092
+ process$1.stdout.write('\u001b[1;3H');
15968
16093
  });
15969
16094
 
15970
16095
  runner.once(EVENT_RUN_END, this.epilogue.bind(this));
@@ -16351,7 +16476,7 @@
16351
16476
  * @param {string} string A message to write to stdout.
16352
16477
  */
16353
16478
  function write(string) {
16354
- process.stdout.write(string);
16479
+ process$1.stdout.write(string);
16355
16480
  }
16356
16481
 
16357
16482
  NyanCat.description = '"nyan cat"';
@@ -16494,8 +16619,8 @@
16494
16619
  XUnit.prototype.write = function(line) {
16495
16620
  if (this.fileStream) {
16496
16621
  this.fileStream.write(line + '\n');
16497
- } else if (typeof process === 'object' && process.stdout) {
16498
- process.stdout.write(line + '\n');
16622
+ } else if (typeof process$1 === 'object' && process$1.stdout) {
16623
+ process$1.stdout.write(line + '\n');
16499
16624
  } else {
16500
16625
  base.consoleLog(line);
16501
16626
  }
@@ -16676,9 +16801,9 @@
16676
16801
  });
16677
16802
 
16678
16803
  runner.once(EVENT_RUN_END, function() {
16679
- process.stdout.write('# TOC\n');
16680
- process.stdout.write(generateTOC(runner.suite));
16681
- process.stdout.write(buf);
16804
+ process$1.stdout.write('# TOC\n');
16805
+ process$1.stdout.write(generateTOC(runner.suite));
16806
+ process$1.stdout.write(buf);
16682
16807
  });
16683
16808
  }
16684
16809
 
@@ -16745,7 +16870,7 @@
16745
16870
 
16746
16871
  // tests started
16747
16872
  runner.on(EVENT_RUN_BEGIN, function() {
16748
- process.stdout.write('\n');
16873
+ process$1.stdout.write('\n');
16749
16874
  cursor.hide();
16750
16875
  });
16751
16876
 
@@ -16764,13 +16889,13 @@
16764
16889
  lastN = n;
16765
16890
 
16766
16891
  cursor.CR();
16767
- process.stdout.write('\u001b[J');
16768
- process.stdout.write(color('progress', ' ' + options.open));
16769
- process.stdout.write(Array(n).join(options.complete));
16770
- process.stdout.write(Array(i).join(options.incomplete));
16771
- process.stdout.write(color('progress', options.close));
16892
+ process$1.stdout.write('\u001b[J');
16893
+ process$1.stdout.write(color('progress', ' ' + options.open));
16894
+ process$1.stdout.write(Array(n).join(options.complete));
16895
+ process$1.stdout.write(Array(i).join(options.incomplete));
16896
+ process$1.stdout.write(color('progress', options.close));
16772
16897
  if (options.verbose) {
16773
- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
16898
+ process$1.stdout.write(color('progress', ' ' + complete + ' of ' + total));
16774
16899
  }
16775
16900
  });
16776
16901
 
@@ -16778,7 +16903,7 @@
16778
16903
  // and the failures if any
16779
16904
  runner.once(EVENT_RUN_END, function() {
16780
16905
  cursor.show();
16781
- process.stdout.write('\n');
16906
+ process$1.stdout.write('\n');
16782
16907
  self.epilogue();
16783
16908
  });
16784
16909
  }
@@ -16849,7 +16974,7 @@
16849
16974
 
16850
16975
  var self = this;
16851
16976
  var width = (base.window.width * 0.75) | 0;
16852
- var stream = process.stdout;
16977
+ var stream = process$1.stdout;
16853
16978
 
16854
16979
  var plane = color('plane', '✈');
16855
16980
  var crashed = -1;
@@ -16888,15 +17013,15 @@
16888
17013
 
16889
17014
  runner.once(EVENT_RUN_END, function() {
16890
17015
  cursor.show();
16891
- process.stdout.write('\n');
17016
+ process$1.stdout.write('\n');
16892
17017
  self.epilogue();
16893
17018
  });
16894
17019
 
16895
17020
  // if cursor is hidden when we ctrl-C, then it will remain hidden unless...
16896
- process.once('SIGINT', function() {
17021
+ process$1.once('SIGINT', function() {
16897
17022
  cursor.show();
16898
17023
  nextTick$1(function() {
16899
- process.kill(process.pid, 'SIGINT');
17024
+ process$1.kill(process$1.pid, 'SIGINT');
16900
17025
  });
16901
17026
  });
16902
17027
  }
@@ -16978,7 +17103,7 @@
16978
17103
  * @param {JSONStream~MochaEvent} event - Mocha event to be output.
16979
17104
  */
16980
17105
  function writeEvent(event) {
16981
- process.stdout.write(JSON.stringify(event) + '\n');
17106
+ process$1.stdout.write(JSON.stringify(event) + '\n');
16982
17107
  }
16983
17108
 
16984
17109
  /**
@@ -17025,7 +17150,7 @@
17025
17150
  });
17026
17151
 
17027
17152
  var name = "mocha";
17028
- var version = "9.0.1";
17153
+ var version = "9.1.1";
17029
17154
  var homepage = "https://mochajs.org/";
17030
17155
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
17031
17156
  var _package = {
@@ -17426,7 +17551,7 @@
17426
17551
  return {
17427
17552
  $$currentRetry: this._currentRetry,
17428
17553
  $$fullTitle: this.fullTitle(),
17429
- $$isPending: this.pending,
17554
+ $$isPending: Boolean(this.pending),
17430
17555
  $$retriedTest: this._retriedTest || null,
17431
17556
  $$slow: this._slow,
17432
17557
  $$titlePath: this.titlePath(),
@@ -18274,6 +18399,7 @@
18274
18399
  * @param {boolean} [options.delay] - Delay root suite execution?
18275
18400
  * @param {boolean} [options.diff] - Show diff on failure?
18276
18401
  * @param {boolean} [options.dryRun] - Report tests without running them?
18402
+ * @param {boolean} [options.failZero] - Fail test run if zero tests?
18277
18403
  * @param {string} [options.fgrep] - Test filter given string.
18278
18404
  * @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
18279
18405
  * @param {boolean} [options.forbidPending] - Pending tests fail the suite?
@@ -18333,6 +18459,7 @@
18333
18459
  'delay',
18334
18460
  'diff',
18335
18461
  'dryRun',
18462
+ 'failZero',
18336
18463
  'forbidOnly',
18337
18464
  'forbidPending',
18338
18465
  'fullTrace',
@@ -18691,7 +18818,7 @@
18691
18818
  Mocha.prototype.grep = function(re) {
18692
18819
  if (utils.isString(re)) {
18693
18820
  // extract args if it's regex-like, i.e: [string, pattern, flag]
18694
- var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
18821
+ var arg = re.match(/^\/(.*)\/([gimy]{0,4})$|.*/);
18695
18822
  this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
18696
18823
  } else {
18697
18824
  this.options.grep = re;
@@ -18888,20 +19015,6 @@
18888
19015
  return this;
18889
19016
  };
18890
19017
 
18891
- /**
18892
- * Enables or disables running tests in dry-run mode.
18893
- *
18894
- * @public
18895
- * @see [CLI option](../#-dry-run)
18896
- * @param {boolean} [dryRun=true] - Whether to activate dry-run mode.
18897
- * @return {Mocha} this
18898
- * @chainable
18899
- */
18900
- Mocha.prototype.dryRun = function(dryRun) {
18901
- this.options.dryRun = dryRun !== false;
18902
- return this;
18903
- };
18904
-
18905
19018
  /**
18906
19019
  * @summary
18907
19020
  * Sets timeout threshold value.
@@ -19028,6 +19141,34 @@
19028
19141
  return this;
19029
19142
  };
19030
19143
 
19144
+ /**
19145
+ * Enables or disables running tests in dry-run mode.
19146
+ *
19147
+ * @public
19148
+ * @see [CLI option](../#-dry-run)
19149
+ * @param {boolean} [dryRun=true] - Whether to activate dry-run mode.
19150
+ * @return {Mocha} this
19151
+ * @chainable
19152
+ */
19153
+ Mocha.prototype.dryRun = function(dryRun) {
19154
+ this.options.dryRun = dryRun !== false;
19155
+ return this;
19156
+ };
19157
+
19158
+ /**
19159
+ * Fails test run if no tests encountered with exit-code 1.
19160
+ *
19161
+ * @public
19162
+ * @see [CLI option](../#-fail-zero)
19163
+ * @param {boolean} [failZero=true] - Whether to fail test run.
19164
+ * @return {Mocha} this
19165
+ * @chainable
19166
+ */
19167
+ Mocha.prototype.failZero = function(failZero) {
19168
+ this.options.failZero = failZero !== false;
19169
+ return this;
19170
+ };
19171
+
19031
19172
  /**
19032
19173
  * Causes tests marked `only` to fail the suite.
19033
19174
  *
@@ -19133,9 +19274,10 @@
19133
19274
  var options = this.options;
19134
19275
  options.files = this.files;
19135
19276
  const runner = new this._runnerClass(suite, {
19277
+ cleanReferencesAfterRun: this._cleanReferencesAfterRun,
19136
19278
  delay: options.delay,
19137
19279
  dryRun: options.dryRun,
19138
- cleanReferencesAfterRun: this._cleanReferencesAfterRun
19280
+ failZero: options.failZero
19139
19281
  });
19140
19282
  statsCollector(runner);
19141
19283
  var reporter = new this._reporter(runner, options);
@@ -19482,7 +19624,7 @@
19482
19624
  * Shim process.stdout.
19483
19625
  */
19484
19626
 
19485
- process.stdout = browserStdout({label: false});
19627
+ process$1.stdout = browserStdout({label: false});
19486
19628
 
19487
19629
 
19488
19630
 
@@ -19515,7 +19657,7 @@
19515
19657
  * Revert to original onerror handler if previously defined.
19516
19658
  */
19517
19659
 
19518
- process.removeListener = function(e, fn) {
19660
+ process$1.removeListener = function(e, fn) {
19519
19661
  if (e === 'uncaughtException') {
19520
19662
  if (originalOnerrorHandler) {
19521
19663
  commonjsGlobal.onerror = originalOnerrorHandler;
@@ -19533,7 +19675,7 @@
19533
19675
  * Implements listenerCount for 'uncaughtException'.
19534
19676
  */
19535
19677
 
19536
- process.listenerCount = function(name) {
19678
+ process$1.listenerCount = function(name) {
19537
19679
  if (name === 'uncaughtException') {
19538
19680
  return uncaughtExceptionHandlers.length;
19539
19681
  }
@@ -19544,7 +19686,7 @@
19544
19686
  * Implements uncaughtException listener.
19545
19687
  */
19546
19688
 
19547
- process.on = function(e, fn) {
19689
+ process$1.on = function(e, fn) {
19548
19690
  if (e === 'uncaughtException') {
19549
19691
  commonjsGlobal.onerror = function(err, url, line) {
19550
19692
  fn(new Error(err + ' (' + url + ':' + line + ')'));
@@ -19554,7 +19696,7 @@
19554
19696
  }
19555
19697
  };
19556
19698
 
19557
- process.listeners = function(e) {
19699
+ process$1.listeners = function(e) {
19558
19700
  if (e === 'uncaughtException') {
19559
19701
  return uncaughtExceptionHandlers;
19560
19702
  }
@@ -19679,7 +19821,7 @@
19679
19821
  * https://github.com/mochajs/mocha/pull/916
19680
19822
  */
19681
19823
 
19682
- mocha$1.process = process;
19824
+ mocha$1.process = process$1;
19683
19825
 
19684
19826
  /**
19685
19827
  * Expose mocha.