mocha 10.2.0 → 10.4.0

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
@@ -1,4 +1,4 @@
1
- // mocha@10.2.0 in javascript ES2018
1
+ // mocha@10.4.0 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) :
@@ -972,6 +972,11 @@
972
972
  ? global$2.TYPED_ARRAY_SUPPORT
973
973
  : true;
974
974
 
975
+ /*
976
+ * Export kMaxLength after typed array support is determined.
977
+ */
978
+ kMaxLength$1();
979
+
975
980
  function kMaxLength$1 () {
976
981
  return Buffer$1.TYPED_ARRAY_SUPPORT
977
982
  ? 0x7fffffff
@@ -8722,6 +8727,11 @@
8722
8727
  ? global$1.TYPED_ARRAY_SUPPORT
8723
8728
  : true;
8724
8729
 
8730
+ /*
8731
+ * Export kMaxLength after typed array support is determined.
8732
+ */
8733
+ kMaxLength();
8734
+
8725
8735
  function kMaxLength () {
8726
8736
  return Buffer.TYPED_ARRAY_SUPPORT
8727
8737
  ? 0x7fffffff
@@ -8813,6 +8823,8 @@
8813
8823
  if (Buffer.TYPED_ARRAY_SUPPORT) {
8814
8824
  Buffer.prototype.__proto__ = Uint8Array.prototype;
8815
8825
  Buffer.__proto__ = Uint8Array;
8826
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
8827
+ Buffer[Symbol.species] === Buffer) ;
8816
8828
  }
8817
8829
 
8818
8830
  function assertSize (size) {
@@ -10456,28 +10468,6 @@
10456
10468
 
10457
10469
  var utils$3 = {};
10458
10470
 
10459
- let urlAlphabet =
10460
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
10461
- let customAlphabet = (alphabet, defaultSize = 21) => {
10462
- return (size = defaultSize) => {
10463
- let id = '';
10464
- let i = size;
10465
- while (i--) {
10466
- id += alphabet[(Math.random() * alphabet.length) | 0];
10467
- }
10468
- return id
10469
- }
10470
- };
10471
- let nanoid = (size = 21) => {
10472
- let id = '';
10473
- let i = size;
10474
- while (i--) {
10475
- id += urlAlphabet[(Math.random() * 64) | 0];
10476
- }
10477
- return id
10478
- };
10479
- var nonSecure = { nanoid, customAlphabet };
10480
-
10481
10471
  var he = {exports: {}};
10482
10472
 
10483
10473
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
@@ -10831,8 +10821,6 @@
10831
10821
  /**
10832
10822
  * Module dependencies.
10833
10823
  */
10834
-
10835
- const {nanoid} = nonSecure;
10836
10824
  var path = require$$1;
10837
10825
  var util = require$$0$1;
10838
10826
  var he$1 = he.exports;
@@ -11438,11 +11426,22 @@
11438
11426
  MOCHA_ID_PROP_NAME
11439
11427
  });
11440
11428
 
11429
+ const uniqueIDBase =
11430
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';
11431
+
11441
11432
  /**
11442
11433
  * Creates a new unique identifier
11434
+ * Does not create cryptographically safe ids.
11435
+ * Trivial copy of nanoid/non-secure
11443
11436
  * @returns {string} Unique identifier
11444
11437
  */
11445
- exports.uniqueID = () => nanoid();
11438
+ exports.uniqueID = () => {
11439
+ let id = '';
11440
+ for (let i = 0; i < 21; i++) {
11441
+ id += uniqueIDBase[(Math.random() * 64) | 0];
11442
+ }
11443
+ return id;
11444
+ };
11446
11445
 
11447
11446
  exports.assignNewMochaID = obj => {
11448
11447
  const id = exports.uniqueID();
@@ -12969,7 +12968,7 @@
12969
12968
  *
12970
12969
  * @memberof Mocha.Runnable
12971
12970
  * @public
12972
- * @return {string}
12971
+ * @return {string[]}
12973
12972
  */
12974
12973
  Runnable$3.prototype.titlePath = function () {
12975
12974
  return this.parent.titlePath().concat([this.title]);
@@ -13712,7 +13711,7 @@
13712
13711
  *
13713
13712
  * @memberof Suite
13714
13713
  * @public
13715
- * @return {string}
13714
+ * @return {string[]}
13716
13715
  */
13717
13716
  Suite.prototype.titlePath = function () {
13718
13717
  var result = [];
@@ -14434,11 +14433,22 @@
14434
14433
  err = thrown2Error(err);
14435
14434
  }
14436
14435
 
14437
- try {
14438
- err.stack =
14439
- this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
14440
- } catch (ignore) {
14441
- // some environments do not take kindly to monkeying with the stack
14436
+ // Filter the stack traces
14437
+ if (!this.fullStackTrace) {
14438
+ const alreadyFiltered = new Set();
14439
+ let currentErr = err;
14440
+
14441
+ while (currentErr && currentErr.stack && !alreadyFiltered.has(currentErr)) {
14442
+ alreadyFiltered.add(currentErr);
14443
+
14444
+ try {
14445
+ currentErr.stack = stackFilter(currentErr.stack);
14446
+ } catch (ignore) {
14447
+ // some environments do not take kindly to monkeying with the stack
14448
+ }
14449
+
14450
+ currentErr = currentErr.cause;
14451
+ }
14442
14452
  }
14443
14453
 
14444
14454
  this.emit(constants$1.EVENT_TEST_FAIL, test, err);
@@ -15469,6 +15479,56 @@
15469
15479
  }
15470
15480
  });
15471
15481
 
15482
+ /**
15483
+ * Traverses err.cause and returns all stack traces
15484
+ *
15485
+ * @private
15486
+ * @param {Error} err
15487
+ * @param {Set<Error>} [seen]
15488
+ * @return {FullErrorStack}
15489
+ */
15490
+ var getFullErrorStack = function (err, seen) {
15491
+ if (seen && seen.has(err)) {
15492
+ return { message: '', msg: '<circular>', stack: '' };
15493
+ }
15494
+
15495
+ var message;
15496
+
15497
+ if (typeof err.inspect === 'function') {
15498
+ message = err.inspect() + '';
15499
+ } else if (err.message && typeof err.message.toString === 'function') {
15500
+ message = err.message + '';
15501
+ } else {
15502
+ message = '';
15503
+ }
15504
+
15505
+ var msg;
15506
+ var stack = err.stack || message;
15507
+ var index = message ? stack.indexOf(message) : -1;
15508
+
15509
+ if (index === -1) {
15510
+ msg = message;
15511
+ } else {
15512
+ index += message.length;
15513
+ msg = stack.slice(0, index);
15514
+ // remove msg from stack
15515
+ stack = stack.slice(index + 1);
15516
+
15517
+ if (err.cause) {
15518
+ seen = seen || new Set();
15519
+ seen.add(err);
15520
+ const causeStack = getFullErrorStack(err.cause, seen);
15521
+ stack += '\n Caused by: ' + causeStack.msg + (causeStack.stack ? '\n' + causeStack.stack : '');
15522
+ }
15523
+ }
15524
+
15525
+ return {
15526
+ message,
15527
+ msg,
15528
+ stack
15529
+ };
15530
+ };
15531
+
15472
15532
  /**
15473
15533
  * Outputs the given `failures` as a list.
15474
15534
  *
@@ -15489,7 +15549,6 @@
15489
15549
  color('error stack', '\n%s\n');
15490
15550
 
15491
15551
  // msg
15492
- var msg;
15493
15552
  var err;
15494
15553
  if (test.err && test.err.multiple) {
15495
15554
  if (multipleTest !== test) {
@@ -15500,25 +15559,8 @@
15500
15559
  } else {
15501
15560
  err = test.err;
15502
15561
  }
15503
- var message;
15504
- if (typeof err.inspect === 'function') {
15505
- message = err.inspect() + '';
15506
- } else if (err.message && typeof err.message.toString === 'function') {
15507
- message = err.message + '';
15508
- } else {
15509
- message = '';
15510
- }
15511
- var stack = err.stack || message;
15512
- var index = message ? stack.indexOf(message) : -1;
15513
15562
 
15514
- if (index === -1) {
15515
- msg = message;
15516
- } else {
15517
- index += message.length;
15518
- msg = stack.slice(0, index);
15519
- // remove msg from stack
15520
- stack = stack.slice(index + 1);
15521
- }
15563
+ var { message, msg, stack } = getFullErrorStack(err);
15522
15564
 
15523
15565
  // uncaught
15524
15566
  if (err.uncaught) {
@@ -15796,6 +15838,15 @@
15796
15838
  Base.consoleLog = consoleLog;
15797
15839
 
15798
15840
  Base.abstract = true;
15841
+
15842
+ /**
15843
+ * An object with all stack traces recursively mounted from each err.cause
15844
+ * @memberof module:lib/reporters/base
15845
+ * @typedef {Object} FullErrorStack
15846
+ * @property {string} message
15847
+ * @property {string} msg
15848
+ * @property {string} stack
15849
+ */
15799
15850
  }(base$1, base$1.exports));
15800
15851
 
15801
15852
  var dot = {exports: {}};
@@ -17296,7 +17347,7 @@
17296
17347
  runner.once(EVENT_RUN_END, function () {
17297
17348
  Base.cursor.show();
17298
17349
  for (var i = 0; i < self.numberOfLines; i++) {
17299
- write('\n');
17350
+ process.stdout.write('\n');
17300
17351
  }
17301
17352
  self.epilogue();
17302
17353
  });
@@ -17332,15 +17383,15 @@
17332
17383
  var stats = this.stats;
17333
17384
 
17334
17385
  function draw(type, n) {
17335
- write(' ');
17336
- write(Base.color(type, n));
17337
- write('\n');
17386
+ process.stdout.write(' ');
17387
+ process.stdout.write(Base.color(type, n));
17388
+ process.stdout.write('\n');
17338
17389
  }
17339
17390
 
17340
17391
  draw('green', stats.passes);
17341
17392
  draw('fail', stats.failures);
17342
17393
  draw('pending', stats.pending);
17343
- write('\n');
17394
+ process.stdout.write('\n');
17344
17395
 
17345
17396
  this.cursorUp(this.numberOfLines);
17346
17397
  };
@@ -17374,9 +17425,9 @@
17374
17425
  var self = this;
17375
17426
 
17376
17427
  this.trajectories.forEach(function (line) {
17377
- write('\u001b[' + self.scoreboardWidth + 'C');
17378
- write(line.join(''));
17379
- write('\n');
17428
+ process.stdout.write('\u001b[' + self.scoreboardWidth + 'C');
17429
+ process.stdout.write(line.join(''));
17430
+ process.stdout.write('\n');
17380
17431
  });
17381
17432
 
17382
17433
  this.cursorUp(this.numberOfLines);
@@ -17393,25 +17444,25 @@
17393
17444
  var dist = '\u001b[' + startWidth + 'C';
17394
17445
  var padding = '';
17395
17446
 
17396
- write(dist);
17397
- write('_,------,');
17398
- write('\n');
17447
+ process.stdout.write(dist);
17448
+ process.stdout.write('_,------,');
17449
+ process.stdout.write('\n');
17399
17450
 
17400
- write(dist);
17451
+ process.stdout.write(dist);
17401
17452
  padding = self.tick ? ' ' : ' ';
17402
- write('_|' + padding + '/\\_/\\ ');
17403
- write('\n');
17453
+ process.stdout.write('_|' + padding + '/\\_/\\ ');
17454
+ process.stdout.write('\n');
17404
17455
 
17405
- write(dist);
17456
+ process.stdout.write(dist);
17406
17457
  padding = self.tick ? '_' : '__';
17407
17458
  var tail = self.tick ? '~' : '^';
17408
- write(tail + '|' + padding + this.face() + ' ');
17409
- write('\n');
17459
+ process.stdout.write(tail + '|' + padding + this.face() + ' ');
17460
+ process.stdout.write('\n');
17410
17461
 
17411
- write(dist);
17462
+ process.stdout.write(dist);
17412
17463
  padding = self.tick ? ' ' : ' ';
17413
- write(padding + '"" "" ');
17414
- write('\n');
17464
+ process.stdout.write(padding + '"" "" ');
17465
+ process.stdout.write('\n');
17415
17466
 
17416
17467
  this.cursorUp(this.numberOfLines);
17417
17468
  };
@@ -17443,7 +17494,7 @@
17443
17494
  */
17444
17495
 
17445
17496
  NyanCat.prototype.cursorUp = function (n) {
17446
- write('\u001b[' + n + 'A');
17497
+ process.stdout.write('\u001b[' + n + 'A');
17447
17498
  };
17448
17499
 
17449
17500
  /**
@@ -17454,7 +17505,7 @@
17454
17505
  */
17455
17506
 
17456
17507
  NyanCat.prototype.cursorDown = function (n) {
17457
- write('\u001b[' + n + 'B');
17508
+ process.stdout.write('\u001b[' + n + 'B');
17458
17509
  };
17459
17510
 
17460
17511
  /**
@@ -17494,15 +17545,6 @@
17494
17545
  return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
17495
17546
  };
17496
17547
 
17497
- /**
17498
- * Stdout helper.
17499
- *
17500
- * @param {string} string A message to write to stdout.
17501
- */
17502
- function write(string) {
17503
- process.stdout.write(string);
17504
- }
17505
-
17506
17548
  NyanCat.description = '"nyan cat"';
17507
17549
  }(nyan));
17508
17550
 
@@ -17668,6 +17710,7 @@
17668
17710
  var attrs = {
17669
17711
  classname: test.parent.fullTitle(),
17670
17712
  name: test.title,
17713
+ file: test.file,
17671
17714
  time: test.duration / 1000 || 0
17672
17715
  };
17673
17716
 
@@ -19076,7 +19119,7 @@
19076
19119
  };
19077
19120
 
19078
19121
  var name = "mocha";
19079
- var version = "10.2.0";
19122
+ var version = "10.4.0";
19080
19123
  var homepage = "https://mochajs.org/";
19081
19124
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19082
19125
  var require$$17 = {