mocha 10.4.0 → 10.5.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.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@10.4.0 in javascript ES2018
1
+ // mocha@10.5.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) :
@@ -16507,143 +16507,6 @@
16507
16507
 
16508
16508
  var html = {exports: {}};
16509
16509
 
16510
- /**
16511
- @module browser/Progress
16512
- */
16513
-
16514
- /**
16515
- * Expose `Progress`.
16516
- */
16517
-
16518
- var progress$1 = Progress;
16519
-
16520
- /**
16521
- * Initialize a new `Progress` indicator.
16522
- */
16523
- function Progress() {
16524
- this.percent = 0;
16525
- this.size(0);
16526
- this.fontSize(11);
16527
- this.font('helvetica, arial, sans-serif');
16528
- }
16529
-
16530
- /**
16531
- * Set progress size to `size`.
16532
- *
16533
- * @public
16534
- * @param {number} size
16535
- * @return {Progress} Progress instance.
16536
- */
16537
- Progress.prototype.size = function (size) {
16538
- this._size = size;
16539
- return this;
16540
- };
16541
-
16542
- /**
16543
- * Set text to `text`.
16544
- *
16545
- * @public
16546
- * @param {string} text
16547
- * @return {Progress} Progress instance.
16548
- */
16549
- Progress.prototype.text = function (text) {
16550
- this._text = text;
16551
- return this;
16552
- };
16553
-
16554
- /**
16555
- * Set font size to `size`.
16556
- *
16557
- * @public
16558
- * @param {number} size
16559
- * @return {Progress} Progress instance.
16560
- */
16561
- Progress.prototype.fontSize = function (size) {
16562
- this._fontSize = size;
16563
- return this;
16564
- };
16565
-
16566
- /**
16567
- * Set font to `family`.
16568
- *
16569
- * @param {string} family
16570
- * @return {Progress} Progress instance.
16571
- */
16572
- Progress.prototype.font = function (family) {
16573
- this._font = family;
16574
- return this;
16575
- };
16576
-
16577
- /**
16578
- * Update percentage to `n`.
16579
- *
16580
- * @param {number} n
16581
- * @return {Progress} Progress instance.
16582
- */
16583
- Progress.prototype.update = function (n) {
16584
- this.percent = n;
16585
- return this;
16586
- };
16587
-
16588
- /**
16589
- * Draw on `ctx`.
16590
- *
16591
- * @param {CanvasRenderingContext2d} ctx
16592
- * @return {Progress} Progress instance.
16593
- */
16594
- Progress.prototype.draw = function (ctx) {
16595
- try {
16596
- var darkMatcher = window.matchMedia('(prefers-color-scheme: dark)');
16597
- var isDarkMode = !!darkMatcher.matches;
16598
- var lightColors = {
16599
- outerCircle: '#9f9f9f',
16600
- innerCircle: '#eee',
16601
- text: '#000'
16602
- };
16603
- var darkColors = {
16604
- outerCircle: '#888',
16605
- innerCircle: '#444',
16606
- text: '#fff'
16607
- };
16608
- var colors = isDarkMode ? darkColors : lightColors;
16609
-
16610
- var percent = Math.min(this.percent, 100);
16611
- var size = this._size;
16612
- var half = size / 2;
16613
- var x = half;
16614
- var y = half;
16615
- var rad = half - 1;
16616
- var fontSize = this._fontSize;
16617
-
16618
- ctx.font = fontSize + 'px ' + this._font;
16619
-
16620
- var angle = Math.PI * 2 * (percent / 100);
16621
- ctx.clearRect(0, 0, size, size);
16622
-
16623
- // outer circle
16624
- ctx.strokeStyle = colors.outerCircle;
16625
- ctx.beginPath();
16626
- ctx.arc(x, y, rad, 0, angle, false);
16627
- ctx.stroke();
16628
-
16629
- // inner circle
16630
- ctx.strokeStyle = colors.innerCircle;
16631
- ctx.beginPath();
16632
- ctx.arc(x, y, rad - 1, 0, angle, true);
16633
- ctx.stroke();
16634
-
16635
- // text
16636
- var text = this._text || (percent | 0) + '%';
16637
- var w = ctx.measureText(text).width;
16638
-
16639
- ctx.fillStyle = colors.text;
16640
- ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
16641
- } catch (ignore) {
16642
- // don't fail if we can't render progress
16643
- }
16644
- return this;
16645
- };
16646
-
16647
16510
  (function (module, exports) {
16648
16511
 
16649
16512
  /* eslint-env browser */
@@ -16656,7 +16519,6 @@
16656
16519
 
16657
16520
  var Base = base$1.exports;
16658
16521
  var utils = utils$3;
16659
- var Progress = progress$1;
16660
16522
  var escapeRe = escapeStringRegexp;
16661
16523
  var constants = runner.constants;
16662
16524
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
@@ -16684,7 +16546,7 @@
16684
16546
 
16685
16547
  var statsTemplate =
16686
16548
  '<ul id="mocha-stats">' +
16687
- '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
16549
+ '<li class="progress-contain"><progress class="progress-element" max="100" value="0"></progress><svg class="progress-ring"><circle class="ring-flatlight" stroke-dasharray="100%,0%"/><circle class="ring-highlight" stroke-dasharray="0%,100%"/></svg><div class="progress-text">0%</div></li>' +
16688
16550
  '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
16689
16551
  '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
16690
16552
  '<li class="duration">duration: <em>0</em>s</li>' +
@@ -16714,24 +16576,15 @@
16714
16576
  var failures = items[2].getElementsByTagName('em')[0];
16715
16577
  var failuresLink = items[2].getElementsByTagName('a')[0];
16716
16578
  var duration = items[3].getElementsByTagName('em')[0];
16717
- var canvas = stat.getElementsByTagName('canvas')[0];
16718
16579
  var report = fragment('<ul id="mocha-report"></ul>');
16719
16580
  var stack = [report];
16720
- var progress;
16721
- var ctx;
16581
+ var progressText = items[0].getElementsByTagName('div')[0];
16582
+ var progressBar = items[0].getElementsByTagName('progress')[0];
16583
+ var progressRing = [
16584
+ items[0].getElementsByClassName('ring-flatlight')[0],
16585
+ items[0].getElementsByClassName('ring-highlight')[0]];
16722
16586
  var root = document.getElementById('mocha');
16723
16587
 
16724
- if (canvas.getContext) {
16725
- var ratio = window.devicePixelRatio || 1;
16726
- canvas.style.width = canvas.width;
16727
- canvas.style.height = canvas.height;
16728
- canvas.width *= ratio;
16729
- canvas.height *= ratio;
16730
- ctx = canvas.getContext('2d');
16731
- ctx.scale(ratio, ratio);
16732
- progress = new Progress();
16733
- }
16734
-
16735
16588
  if (!root) {
16736
16589
  return error('#mocha div missing, add it to your document');
16737
16590
  }
@@ -16761,10 +16614,6 @@
16761
16614
  root.appendChild(stat);
16762
16615
  root.appendChild(report);
16763
16616
 
16764
- if (progress) {
16765
- progress.size(40);
16766
- }
16767
-
16768
16617
  runner.on(EVENT_SUITE_BEGIN, function (suite) {
16769
16618
  if (suite.root) {
16770
16619
  return;
@@ -16880,8 +16729,26 @@
16880
16729
  function updateStats() {
16881
16730
  // TODO: add to stats
16882
16731
  var percent = ((stats.tests / runner.total) * 100) | 0;
16883
- if (progress) {
16884
- progress.update(percent).draw(ctx);
16732
+ progressBar.value = percent;
16733
+ if (progressText) {
16734
+ // setting a toFixed that is too low, makes small changes to progress not shown
16735
+ // setting it too high, makes the progress text longer then it needs to
16736
+ // to address this, calculate the toFixed based on the magnitude of total
16737
+ var decimalPlaces = Math.ceil(Math.log10(runner.total / 100));
16738
+ text(
16739
+ progressText,
16740
+ percent.toFixed(Math.min(Math.max(decimalPlaces, 0), 100)) + '%'
16741
+ );
16742
+ }
16743
+ if (progressRing) {
16744
+ var radius = parseFloat(getComputedStyle(progressRing[0]).getPropertyValue('r'));
16745
+ var wholeArc = Math.PI * 2 * radius;
16746
+ var highlightArc = percent * (wholeArc / 100);
16747
+ // The progress ring is in 2 parts, the flatlight color and highlight color.
16748
+ // Rendering both on top of the other, seems to make a 3rd color on the edges.
16749
+ // To create 1 whole ring with 2 colors, both parts are inverse of the other.
16750
+ progressRing[0].style['stroke-dasharray'] = `0,${highlightArc}px,${wholeArc}px`;
16751
+ progressRing[1].style['stroke-dasharray'] = `${highlightArc}px,${wholeArc}px`;
16885
16752
  }
16886
16753
 
16887
16754
  // update stats
@@ -19119,7 +18986,7 @@
19119
18986
  };
19120
18987
 
19121
18988
  var name = "mocha";
19122
- var version = "10.4.0";
18989
+ var version = "10.5.1";
19123
18990
  var homepage = "https://mochajs.org/";
19124
18991
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19125
18992
  var require$$17 = {
@@ -20518,8 +20385,8 @@
20518
20385
 
20519
20386
  process.on = function (e, fn) {
20520
20387
  if (e === 'uncaughtException') {
20521
- commonjsGlobal.onerror = function (err, url, line) {
20522
- fn(new Error(err + ' (' + url + ':' + line + ')'));
20388
+ commonjsGlobal.onerror = function (msg, url, line, col, err) {
20389
+ fn(err || new Error(msg + ' (' + url + ':' + line + ':' + col + ')'));
20523
20390
  return !mocha.options.allowUncaught;
20524
20391
  };
20525
20392
  uncaughtExceptionHandlers.push(fn);