mocha 6.1.3 → 6.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mocha.js CHANGED
@@ -1477,7 +1477,7 @@ exports.Test = require('./test');
1477
1477
  * @param {boolean} [options.ignoreLeaks] - Ignore global leaks?
1478
1478
  * @param {boolean} [options.invert] - Invert test filter matches?
1479
1479
  * @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
1480
- * @param {string} [options.reporter] - Reporter name.
1480
+ * @param {string|constructor} [options.reporter] - Reporter name or constructor.
1481
1481
  * @param {Object} [options.reporterOption] - Reporter settings object.
1482
1482
  * @param {number} [options.retries] - Number of times to retry failed tests.
1483
1483
  * @param {number} [options.slow] - Slow threshold value.
@@ -1500,6 +1500,10 @@ function Mocha(options) {
1500
1500
  options.color = 'color' in options ? options.color : options.useColors;
1501
1501
  }
1502
1502
 
1503
+ // Globals are passed in as options.global, with options.globals for backward compatibility.
1504
+ options.globals = options.global || options.globals || [];
1505
+ delete options.global;
1506
+
1503
1507
  this.grep(options.grep)
1504
1508
  .fgrep(options.fgrep)
1505
1509
  .ui(options.ui)
@@ -1553,7 +1557,7 @@ function Mocha(options) {
1553
1557
  * Enables or disables bailing on the first failure.
1554
1558
  *
1555
1559
  * @public
1556
- * @see {@link https://mochajs.org/#-b---bail|CLI option}
1560
+ * @see {@link /#-bail-b|CLI option}
1557
1561
  * @param {boolean} [bail=true] - Whether to bail on first error.
1558
1562
  * @returns {Mocha} this
1559
1563
  * @chainable
@@ -1574,7 +1578,7 @@ Mocha.prototype.bail = function(bail) {
1574
1578
  * Useful for generic setup code that must be included within test suite.
1575
1579
  *
1576
1580
  * @public
1577
- * @see {@link https://mochajs.org/#--file-file|CLI option}
1581
+ * @see {@link /#-file-filedirectoryglob|CLI option}
1578
1582
  * @param {string} file - Pathname of file to be loaded.
1579
1583
  * @returns {Mocha} this
1580
1584
  * @chainable
@@ -1588,8 +1592,8 @@ Mocha.prototype.addFile = function(file) {
1588
1592
  * Sets reporter to `reporter`, defaults to "spec".
1589
1593
  *
1590
1594
  * @public
1591
- * @see {@link https://mochajs.org/#-r---reporter-name|CLI option}
1592
- * @see {@link https://mochajs.org/#reporters|Reporters}
1595
+ * @see {@link /#-reporter-name-r-name|CLI option}
1596
+ * @see {@link /#reporters|Reporters}
1593
1597
  * @param {String|Function} reporter - Reporter name or constructor.
1594
1598
  * @param {Object} [reporterOptions] - Options used to configure the reporter.
1595
1599
  * @returns {Mocha} this
@@ -1655,8 +1659,8 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {
1655
1659
  * Sets test UI `name`, defaults to "bdd".
1656
1660
  *
1657
1661
  * @public
1658
- * @see {@link https://mochajs.org/#-u---ui-name|CLI option}
1659
- * @see {@link https://mochajs.org/#interfaces|Interface DSLs}
1662
+ * @see {@link /#-ui-name-u-name|CLI option}
1663
+ * @see {@link /#interfaces|Interface DSLs}
1660
1664
  * @param {string|Function} [ui=bdd] - Interface name or class.
1661
1665
  * @returns {Mocha} this
1662
1666
  * @chainable
@@ -1794,7 +1798,7 @@ Mocha.prototype.fgrep = function(str) {
1794
1798
  * <strong>Previous filter value will be overwritten on each call!</strong>
1795
1799
  *
1796
1800
  * @public
1797
- * @see {@link https://mochajs.org/#-g---grep-pattern|CLI option}
1801
+ * @see {@link /#grep-regexp-g-regexp|CLI option}
1798
1802
  * @see {@link Mocha#fgrep}
1799
1803
  * @see {@link Mocha#invert}
1800
1804
  * @param {RegExp|String} re - Regular expression used to select tests.
@@ -1864,7 +1868,7 @@ Mocha.prototype.ignoreLeaks = function(ignoreLeaks) {
1864
1868
  * Enables checking for global variables leaked while running tests.
1865
1869
  *
1866
1870
  * @public
1867
- * @see {@link https://mochajs.org/#--check-leaks|CLI option}
1871
+ * @see {@link /#-check-leaks|CLI option}
1868
1872
  * @see {@link Mocha#ignoreLeaks}
1869
1873
  * @return {Mocha} this
1870
1874
  * @chainable
@@ -1934,7 +1938,7 @@ Mocha.prototype._growl = growl.notify;
1934
1938
  * Specifies whitelist of variable names to be expected in global scope.
1935
1939
  *
1936
1940
  * @public
1937
- * @see {@link https://mochajs.org/#--globals-names|CLI option}
1941
+ * @see {@link /#-global-variable-name|CLI option}
1938
1942
  * @see {@link Mocha#checkLeaks}
1939
1943
  * @param {String[]|String} globals - Accepted global variable name(s).
1940
1944
  * @return {Mocha} this
@@ -1945,9 +1949,12 @@ Mocha.prototype._growl = growl.notify;
1945
1949
  * mocha.globals(['jQuery', 'MyLib']);
1946
1950
  */
1947
1951
  Mocha.prototype.globals = function(globals) {
1948
- this.options.globals = (this.options.globals || [])
1952
+ this.options.globals = this.options.globals
1949
1953
  .concat(globals)
1950
- .filter(Boolean);
1954
+ .filter(Boolean)
1955
+ .filter(function(elt, idx, arr) {
1956
+ return arr.indexOf(elt) === idx;
1957
+ });
1951
1958
  return this;
1952
1959
  };
1953
1960
 
@@ -2002,9 +2009,8 @@ Mocha.prototype.hideDiff = function(hideDiff) {
2002
2009
  * If the value is `0`, timeouts will be disabled.
2003
2010
  *
2004
2011
  * @public
2005
- * @see {@link https://mochajs.org/#-t---timeout-ms|CLI option}
2006
- * @see {@link https://mochajs.org/#--no-timeouts|CLI option}
2007
- * @see {@link https://mochajs.org/#timeouts|Timeouts}
2012
+ * @see {@link /#-timeout-ms-t-ms|CLI option}
2013
+ * @see {@link /#timeouts|Timeouts}
2008
2014
  * @see {@link Mocha#enableTimeouts}
2009
2015
  * @param {number|string} msecs - Timeout threshold value.
2010
2016
  * @return {Mocha} this
@@ -2027,7 +2033,7 @@ Mocha.prototype.timeout = function(msecs) {
2027
2033
  * Sets the number of times to retry failed tests.
2028
2034
  *
2029
2035
  * @public
2030
- * @see {@link https://mochajs.org/#retry-tests|Retry Tests}
2036
+ * @see {@link /#retry-tests|Retry Tests}
2031
2037
  * @param {number} retry - Number of times to retry failed tests.
2032
2038
  * @return {Mocha} this
2033
2039
  * @chainable
@@ -2045,7 +2051,7 @@ Mocha.prototype.retries = function(n) {
2045
2051
  * Sets slowness threshold value.
2046
2052
  *
2047
2053
  * @public
2048
- * @see {@link https://mochajs.org/#-s---slow-ms|CLI option}
2054
+ * @see {@link /#-slow-ms-s-ms|CLI option}
2049
2055
  * @param {number} msecs - Slowness threshold value.
2050
2056
  * @return {Mocha} this
2051
2057
  * @chainable
@@ -2067,8 +2073,7 @@ Mocha.prototype.slow = function(msecs) {
2067
2073
  * Enables or disables timeouts.
2068
2074
  *
2069
2075
  * @public
2070
- * @see {@link https://mochajs.org/#-t---timeout-ms|CLI option}
2071
- * @see {@link https://mochajs.org/#--no-timeouts|CLI option}
2076
+ * @see {@link /#-timeout-ms-t-ms|CLI option}
2072
2077
  * @param {boolean} enableTimeouts - Whether to enable timeouts.
2073
2078
  * @return {Mocha} this
2074
2079
  * @chainable
@@ -2124,7 +2129,7 @@ Mocha.prototype.allowUncaught = function() {
2124
2129
  * Used to perform asynch operations before any suites are run.
2125
2130
  *
2126
2131
  * @public
2127
- * @see {@link https://mochajs.org/#delayed-root-suite|delayed root suite}
2132
+ * @see {@link /#delayed-root-suite|delayed root suite}
2128
2133
  * @returns {Mocha} this
2129
2134
  * @chainable
2130
2135
  */
@@ -2292,7 +2297,12 @@ exports = module.exports = Base;
2292
2297
  * Check if both stdio streams are associated with a tty.
2293
2298
  */
2294
2299
 
2295
- var isatty = tty.isatty(1) && tty.isatty(2);
2300
+ var isatty = process.stdout.isTTY && process.stderr.isTTY;
2301
+
2302
+ /**
2303
+ * Save log references to avoid tests interfering (see GH-3604).
2304
+ */
2305
+ var consoleLog = console.log;
2296
2306
 
2297
2307
  /**
2298
2308
  * Enable coloring by default, except in the browser interface.
@@ -2459,7 +2469,8 @@ var generateDiff = (exports.generateDiff = function(actual, expected) {
2459
2469
  * Error property
2460
2470
  */
2461
2471
  exports.list = function(failures) {
2462
- console.log();
2472
+ var multipleErr, multipleTest;
2473
+ Base.consoleLog();
2463
2474
  failures.forEach(function(test, i) {
2464
2475
  // format
2465
2476
  var fmt =
@@ -2469,7 +2480,16 @@ exports.list = function(failures) {
2469
2480
 
2470
2481
  // msg
2471
2482
  var msg;
2472
- var err = test.err;
2483
+ var err;
2484
+ if (test.err && test.err.multiple) {
2485
+ if (multipleTest !== test) {
2486
+ multipleTest = test;
2487
+ multipleErr = [test.err].concat(test.err.multiple);
2488
+ }
2489
+ err = multipleErr.shift();
2490
+ } else {
2491
+ err = test.err;
2492
+ }
2473
2493
  var message;
2474
2494
  if (err.message && typeof err.message.toString === 'function') {
2475
2495
  message = err.message + '';
@@ -2520,7 +2540,7 @@ exports.list = function(failures) {
2520
2540
  testTitle += str;
2521
2541
  });
2522
2542
 
2523
- console.log(fmt, i + 1, testTitle, msg, stack);
2543
+ Base.consoleLog(fmt, i + 1, testTitle, msg, stack);
2524
2544
  });
2525
2545
  };
2526
2546
 
@@ -2560,7 +2580,12 @@ function Base(runner, options) {
2560
2580
  if (showDiff(err)) {
2561
2581
  stringifyDiffObjs(err);
2562
2582
  }
2563
- test.err = err;
2583
+ // more than one error per test
2584
+ if (test.err && err instanceof Error) {
2585
+ test.err.multiple = (test.err.multiple || []).concat(err);
2586
+ } else {
2587
+ test.err = err;
2588
+ }
2564
2589
  failures.push(test);
2565
2590
  });
2566
2591
  }
@@ -2569,13 +2594,13 @@ function Base(runner, options) {
2569
2594
  * Outputs common epilogue used by many of the bundled reporters.
2570
2595
  *
2571
2596
  * @public
2572
- * @memberof Mocha.reporters.Base
2597
+ * @memberof Mocha.reporters
2573
2598
  */
2574
2599
  Base.prototype.epilogue = function() {
2575
2600
  var stats = this.stats;
2576
2601
  var fmt;
2577
2602
 
2578
- console.log();
2603
+ Base.consoleLog();
2579
2604
 
2580
2605
  // passes
2581
2606
  fmt =
@@ -2583,26 +2608,26 @@ Base.prototype.epilogue = function() {
2583
2608
  color('green', ' %d passing') +
2584
2609
  color('light', ' (%s)');
2585
2610
 
2586
- console.log(fmt, stats.passes || 0, milliseconds(stats.duration));
2611
+ Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration));
2587
2612
 
2588
2613
  // pending
2589
2614
  if (stats.pending) {
2590
2615
  fmt = color('pending', ' ') + color('pending', ' %d pending');
2591
2616
 
2592
- console.log(fmt, stats.pending);
2617
+ Base.consoleLog(fmt, stats.pending);
2593
2618
  }
2594
2619
 
2595
2620
  // failures
2596
2621
  if (stats.failures) {
2597
2622
  fmt = color('fail', ' %d failing');
2598
2623
 
2599
- console.log(fmt, stats.failures);
2624
+ Base.consoleLog(fmt, stats.failures);
2600
2625
 
2601
2626
  Base.list(this.failures);
2602
- console.log();
2627
+ Base.consoleLog();
2603
2628
  }
2604
2629
 
2605
- console.log();
2630
+ Base.consoleLog();
2606
2631
  };
2607
2632
 
2608
2633
  /**
@@ -2755,6 +2780,8 @@ function sameType(a, b) {
2755
2780
  return objToString.call(a) === objToString.call(b);
2756
2781
  }
2757
2782
 
2783
+ Base.consoleLog = consoleLog;
2784
+
2758
2785
  Base.abstract = true;
2759
2786
 
2760
2787
  }).call(this,require('_process'))
@@ -2805,41 +2832,45 @@ function Doc(runner, options) {
2805
2832
  return;
2806
2833
  }
2807
2834
  ++indents;
2808
- console.log('%s<section class="suite">', indent());
2835
+ Base.consoleLog('%s<section class="suite">', indent());
2809
2836
  ++indents;
2810
- console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
2811
- console.log('%s<dl>', indent());
2837
+ Base.consoleLog('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
2838
+ Base.consoleLog('%s<dl>', indent());
2812
2839
  });
2813
2840
 
2814
2841
  runner.on(EVENT_SUITE_END, function(suite) {
2815
2842
  if (suite.root) {
2816
2843
  return;
2817
2844
  }
2818
- console.log('%s</dl>', indent());
2845
+ Base.consoleLog('%s</dl>', indent());
2819
2846
  --indents;
2820
- console.log('%s</section>', indent());
2847
+ Base.consoleLog('%s</section>', indent());
2821
2848
  --indents;
2822
2849
  });
2823
2850
 
2824
2851
  runner.on(EVENT_TEST_PASS, function(test) {
2825
- console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
2852
+ Base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.title));
2826
2853
  var code = utils.escape(utils.clean(test.body));
2827
- console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
2854
+ Base.consoleLog('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
2828
2855
  });
2829
2856
 
2830
2857
  runner.on(EVENT_TEST_FAIL, function(test, err) {
2831
- console.log(
2858
+ Base.consoleLog(
2832
2859
  '%s <dt class="error">%s</dt>',
2833
2860
  indent(),
2834
2861
  utils.escape(test.title)
2835
2862
  );
2836
2863
  var code = utils.escape(utils.clean(test.body));
2837
- console.log(
2864
+ Base.consoleLog(
2838
2865
  '%s <dd class="error"><pre><code>%s</code></pre></dd>',
2839
2866
  indent(),
2840
2867
  code
2841
2868
  );
2842
- console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
2869
+ Base.consoleLog(
2870
+ '%s <dd class="error">%s</dd>',
2871
+ indent(),
2872
+ utils.escape(err)
2873
+ );
2843
2874
  });
2844
2875
  }
2845
2876
 
@@ -2917,7 +2948,7 @@ function Dot(runner, options) {
2917
2948
  });
2918
2949
 
2919
2950
  runner.once(EVENT_RUN_END, function() {
2920
- console.log();
2951
+ process.stdout.write('\n');
2921
2952
  self.epilogue();
2922
2953
  });
2923
2954
  }
@@ -3291,8 +3322,8 @@ function hideSuitesWithout(classname) {
3291
3322
  */
3292
3323
  function unhide() {
3293
3324
  var els = document.getElementsByClassName('suite hidden');
3294
- for (var i = 0; i < els.length; ++i) {
3295
- els[i].className = els[i].className.replace('suite hidden', 'suite');
3325
+ while (els.length > 0) {
3326
+ els[0].className = els[0].className.replace('suite hidden', 'suite');
3296
3327
  }
3297
3328
  }
3298
3329
 
@@ -3677,7 +3708,7 @@ function Landing(runner, options) {
3677
3708
 
3678
3709
  runner.once(EVENT_RUN_END, function() {
3679
3710
  cursor.show();
3680
- console.log();
3711
+ process.stdout.write('\n');
3681
3712
  self.epilogue();
3682
3713
  });
3683
3714
  }
@@ -3735,7 +3766,7 @@ function List(runner, options) {
3735
3766
  var n = 0;
3736
3767
 
3737
3768
  runner.on(EVENT_RUN_BEGIN, function() {
3738
- console.log();
3769
+ Base.consoleLog();
3739
3770
  });
3740
3771
 
3741
3772
  runner.on(EVENT_TEST_BEGIN, function(test) {
@@ -3744,7 +3775,7 @@ function List(runner, options) {
3744
3775
 
3745
3776
  runner.on(EVENT_TEST_PENDING, function(test) {
3746
3777
  var fmt = color('checkmark', ' -') + color('pending', ' %s');
3747
- console.log(fmt, test.fullTitle());
3778
+ Base.consoleLog(fmt, test.fullTitle());
3748
3779
  });
3749
3780
 
3750
3781
  runner.on(EVENT_TEST_PASS, function(test) {
@@ -3753,12 +3784,12 @@ function List(runner, options) {
3753
3784
  color('pass', ' %s: ') +
3754
3785
  color(test.speed, '%dms');
3755
3786
  cursor.CR();
3756
- console.log(fmt, test.fullTitle(), test.duration);
3787
+ Base.consoleLog(fmt, test.fullTitle(), test.duration);
3757
3788
  });
3758
3789
 
3759
3790
  runner.on(EVENT_TEST_FAIL, function(test) {
3760
3791
  cursor.CR();
3761
- console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
3792
+ Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle());
3762
3793
  });
3763
3794
 
3764
3795
  runner.once(EVENT_RUN_END, self.epilogue.bind(self));
@@ -4286,7 +4317,7 @@ function Progress(runner, options) {
4286
4317
 
4287
4318
  // tests started
4288
4319
  runner.on(EVENT_RUN_BEGIN, function() {
4289
- console.log();
4320
+ process.stdout.write('\n');
4290
4321
  cursor.hide();
4291
4322
  });
4292
4323
 
@@ -4319,7 +4350,7 @@ function Progress(runner, options) {
4319
4350
  // and the failures if any
4320
4351
  runner.once(EVENT_RUN_END, function() {
4321
4352
  cursor.show();
4322
- console.log();
4353
+ process.stdout.write('\n');
4323
4354
  self.epilogue();
4324
4355
  });
4325
4356
  }
@@ -4381,24 +4412,24 @@ function Spec(runner, options) {
4381
4412
  }
4382
4413
 
4383
4414
  runner.on(EVENT_RUN_BEGIN, function() {
4384
- console.log();
4415
+ Base.consoleLog();
4385
4416
  });
4386
4417
 
4387
4418
  runner.on(EVENT_SUITE_BEGIN, function(suite) {
4388
4419
  ++indents;
4389
- console.log(color('suite', '%s%s'), indent(), suite.title);
4420
+ Base.consoleLog(color('suite', '%s%s'), indent(), suite.title);
4390
4421
  });
4391
4422
 
4392
4423
  runner.on(EVENT_SUITE_END, function() {
4393
4424
  --indents;
4394
4425
  if (indents === 1) {
4395
- console.log();
4426
+ Base.consoleLog();
4396
4427
  }
4397
4428
  });
4398
4429
 
4399
4430
  runner.on(EVENT_TEST_PENDING, function(test) {
4400
4431
  var fmt = indent() + color('pending', ' - %s');
4401
- console.log(fmt, test.title);
4432
+ Base.consoleLog(fmt, test.title);
4402
4433
  });
4403
4434
 
4404
4435
  runner.on(EVENT_TEST_PASS, function(test) {
@@ -4408,19 +4439,19 @@ function Spec(runner, options) {
4408
4439
  indent() +
4409
4440
  color('checkmark', ' ' + Base.symbols.ok) +
4410
4441
  color('pass', ' %s');
4411
- console.log(fmt, test.title);
4442
+ Base.consoleLog(fmt, test.title);
4412
4443
  } else {
4413
4444
  fmt =
4414
4445
  indent() +
4415
4446
  color('checkmark', ' ' + Base.symbols.ok) +
4416
4447
  color('pass', ' %s') +
4417
4448
  color(test.speed, ' (%dms)');
4418
- console.log(fmt, test.title, test.duration);
4449
+ Base.consoleLog(fmt, test.title, test.duration);
4419
4450
  }
4420
4451
  });
4421
4452
 
4422
4453
  runner.on(EVENT_TEST_FAIL, function(test) {
4423
- console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
4454
+ Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title);
4424
4455
  });
4425
4456
 
4426
4457
  runner.once(EVENT_RUN_END, self.epilogue.bind(self));
@@ -4877,7 +4908,7 @@ XUnit.prototype.write = function(line) {
4877
4908
  } else if (typeof process === 'object' && process.stdout) {
4878
4909
  process.stdout.write(line + '\n');
4879
4910
  } else {
4880
- console.log(line);
4911
+ Base.consoleLog(line);
4881
4912
  }
4882
4913
  };
4883
4914
 
@@ -5596,7 +5627,7 @@ function Runner(suite, delay) {
5596
5627
  });
5597
5628
  this._defaultGrep = /.*/;
5598
5629
  this.grep(this._defaultGrep);
5599
- this.globals(this.globalProps().concat(extraGlobals()));
5630
+ this.globals(this.globalProps());
5600
5631
  }
5601
5632
 
5602
5633
  /**
@@ -6320,7 +6351,7 @@ Runner.prototype.uncaught = function(err) {
6320
6351
  }
6321
6352
 
6322
6353
  // bail
6323
- this.emit(constants.EVENT_RUN_END);
6354
+ this.abort();
6324
6355
  };
6325
6356
 
6326
6357
  /**
@@ -6471,30 +6502,6 @@ function thrown2Error(err) {
6471
6502
  );
6472
6503
  }
6473
6504
 
6474
- /**
6475
- * Array of globals dependent on the environment.
6476
- *
6477
- * @return {Array}
6478
- * @deprecated
6479
- * @todo remove; long since unsupported
6480
- * @private
6481
- */
6482
- function extraGlobals() {
6483
- if (typeof process === 'object' && typeof process.version === 'string') {
6484
- var parts = process.version.split('.');
6485
- var nodeVersion = parts.reduce(function(a, v) {
6486
- return (a << 8) | v;
6487
- });
6488
-
6489
- // 'errno' was renamed to process._errno in v0.9.11.
6490
- if (nodeVersion < 0x00090b) {
6491
- return ['errno'];
6492
- }
6493
- }
6494
-
6495
- return [];
6496
- }
6497
-
6498
6505
  Runner.constants = constants;
6499
6506
 
6500
6507
  /**
@@ -7854,32 +7861,41 @@ function isHiddenOnUnix(pathname) {
7854
7861
  *
7855
7862
  * @public
7856
7863
  * @memberof Mocha.utils
7857
- * @todo Fix extension handling
7858
7864
  * @param {string} filepath - Base path to start searching from.
7859
- * @param {string[]} extensions - File extensions to look for.
7860
- * @param {boolean} recursive - Whether to recurse into subdirectories.
7865
+ * @param {string[]} [extensions=[]] - File extensions to look for.
7866
+ * @param {boolean} [recursive=false] - Whether to recurse into subdirectories.
7861
7867
  * @return {string[]} An array of paths.
7862
7868
  * @throws {Error} if no files match pattern.
7863
7869
  * @throws {TypeError} if `filepath` is directory and `extensions` not provided.
7864
7870
  */
7865
7871
  exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
7872
+ extensions = extensions || [];
7873
+ recursive = recursive || false;
7866
7874
  var files = [];
7867
7875
  var stat;
7868
7876
 
7869
7877
  if (!fs.existsSync(filepath)) {
7870
- if (fs.existsSync(filepath + '.js')) {
7871
- filepath += '.js';
7878
+ var pattern;
7879
+ if (glob.hasMagic(filepath)) {
7880
+ // Handle glob as is without extensions
7881
+ pattern = filepath;
7872
7882
  } else {
7873
- // Handle glob
7874
- files = glob.sync(filepath);
7875
- if (!files.length) {
7876
- throw createNoFilesMatchPatternError(
7877
- 'Cannot find any files matching pattern ' + exports.dQuote(filepath),
7878
- filepath
7879
- );
7880
- }
7881
- return files;
7883
+ // glob pattern e.g. 'filepath+(.js|.ts)'
7884
+ var strExtensions = extensions
7885
+ .map(function(v) {
7886
+ return '.' + v;
7887
+ })
7888
+ .join('|');
7889
+ pattern = filepath + '+(' + strExtensions + ')';
7890
+ }
7891
+ files = glob.sync(pattern, {nodir: true});
7892
+ if (!files.length) {
7893
+ throw createNoFilesMatchPatternError(
7894
+ 'Cannot find any files matching pattern ' + exports.dQuote(filepath),
7895
+ filepath
7896
+ );
7882
7897
  }
7898
+ return files;
7883
7899
  }
7884
7900
 
7885
7901
  // Handle file
@@ -7910,7 +7926,7 @@ exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
7910
7926
  // ignore error
7911
7927
  return;
7912
7928
  }
7913
- if (!extensions) {
7929
+ if (!extensions.length) {
7914
7930
  throw createMissingArgumentError(
7915
7931
  util.format(
7916
7932
  'Argument %s required when argument %s is a directory',
@@ -8006,7 +8022,8 @@ exports.stackTraceFilter = function() {
8006
8022
  function isMochaInternal(line) {
8007
8023
  return (
8008
8024
  ~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
8009
- ~line.indexOf(slash + 'mocha.js')
8025
+ ~line.indexOf(slash + 'mocha.js') ||
8026
+ ~line.indexOf(slash + 'mocha.min.js')
8010
8027
  );
8011
8028
  }
8012
8029
 
@@ -18069,7 +18086,7 @@ function hasOwnProperty(obj, prop) {
18069
18086
  },{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
18070
18087
  module.exports={
18071
18088
  "name": "mocha",
18072
- "version": "6.1.3",
18089
+ "version": "6.2.2",
18073
18090
  "homepage": "https://mochajs.org/",
18074
18091
  "notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
18075
18092
  }