mocha 6.2.1 → 7.0.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/CHANGELOG.md +74 -0
- package/README.md +26 -26
- package/bin/mocha +12 -43
- package/lib/cli/node-flags.js +5 -2
- package/lib/cli/one-and-dones.js +2 -2
- package/lib/cli/options.js +4 -34
- package/lib/cli/run-helpers.js +4 -3
- package/lib/cli/run-option-metadata.js +6 -5
- package/lib/cli/run.js +24 -11
- package/lib/cli/watch-run.js +116 -31
- package/lib/mocha.js +137 -102
- package/lib/mocharc.json +2 -1
- package/lib/reporters/base.js +33 -8
- package/lib/reporters/html.js +2 -2
- package/lib/reporters/xunit.js +3 -3
- package/lib/runnable.js +16 -17
- package/lib/runner.js +76 -45
- package/lib/utils.js +0 -74
- package/mocha.js +271 -254
- package/package.json +31 -6
- package/bin/options.js +0 -10
package/mocha.js
CHANGED
|
@@ -1463,28 +1463,26 @@ exports.Test = require('./test');
|
|
|
1463
1463
|
* @param {boolean} [options.allowUncaught] - Propagate uncaught errors?
|
|
1464
1464
|
* @param {boolean} [options.asyncOnly] - Force `done` callback or promise?
|
|
1465
1465
|
* @param {boolean} [options.bail] - Bail after first test failure?
|
|
1466
|
-
* @param {boolean} [options.checkLeaks] -
|
|
1466
|
+
* @param {boolean} [options.checkLeaks] - Check for global variable leaks?
|
|
1467
|
+
* @param {boolean} [options.color] - Color TTY output from reporter?
|
|
1467
1468
|
* @param {boolean} [options.delay] - Delay root suite execution?
|
|
1468
|
-
* @param {boolean} [options.
|
|
1469
|
+
* @param {boolean} [options.diff] - Show diff on failure?
|
|
1469
1470
|
* @param {string} [options.fgrep] - Test filter given string.
|
|
1470
1471
|
* @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
|
|
1471
1472
|
* @param {boolean} [options.forbidPending] - Pending tests fail the suite?
|
|
1472
|
-
* @param {boolean} [options.
|
|
1473
|
+
* @param {boolean} [options.fullTrace] - Full stacktrace upon failure?
|
|
1473
1474
|
* @param {string[]} [options.global] - Variables expected in global scope.
|
|
1474
1475
|
* @param {RegExp|string} [options.grep] - Test filter given regular expression.
|
|
1475
1476
|
* @param {boolean} [options.growl] - Enable desktop notifications?
|
|
1476
|
-
* @param {boolean} [options.
|
|
1477
|
-
* @param {boolean} [options.ignoreLeaks] - Ignore global leaks?
|
|
1477
|
+
* @param {boolean} [options.inlineDiffs] - Display inline diffs?
|
|
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.
|
|
1484
1484
|
* @param {number|string} [options.timeout] - Timeout threshold value.
|
|
1485
1485
|
* @param {string} [options.ui] - Interface name.
|
|
1486
|
-
* @param {boolean} [options.color] - Color TTY output from reporter?
|
|
1487
|
-
* @param {boolean} [options.useInlineDiffs] - Use inline diffs?
|
|
1488
1486
|
*/
|
|
1489
1487
|
function Mocha(options) {
|
|
1490
1488
|
options = utils.assign({}, mocharc, options || {});
|
|
@@ -1493,35 +1491,12 @@ function Mocha(options) {
|
|
|
1493
1491
|
// root suite
|
|
1494
1492
|
this.suite = new exports.Suite('', new exports.Context(), true);
|
|
1495
1493
|
|
|
1496
|
-
if ('useColors' in options) {
|
|
1497
|
-
utils.deprecate(
|
|
1498
|
-
'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
|
|
1499
|
-
);
|
|
1500
|
-
options.color = 'color' in options ? options.color : options.useColors;
|
|
1501
|
-
}
|
|
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
|
-
|
|
1507
1494
|
this.grep(options.grep)
|
|
1508
1495
|
.fgrep(options.fgrep)
|
|
1509
1496
|
.ui(options.ui)
|
|
1510
|
-
.
|
|
1511
|
-
.reporter(options.reporter, options.reporterOptions)
|
|
1512
|
-
.useColors(options.color)
|
|
1497
|
+
.reporter(options.reporter, options.reporterOption)
|
|
1513
1498
|
.slow(options.slow)
|
|
1514
|
-
.
|
|
1515
|
-
.globals(options.globals);
|
|
1516
|
-
|
|
1517
|
-
if ('enableTimeouts' in options) {
|
|
1518
|
-
utils.deprecate(
|
|
1519
|
-
'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
|
|
1520
|
-
);
|
|
1521
|
-
if (options.enableTimeouts === false) {
|
|
1522
|
-
this.timeout(0);
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1499
|
+
.global(options.global);
|
|
1525
1500
|
|
|
1526
1501
|
// this guard exists because Suite#timeout does not consider `undefined` to be valid input
|
|
1527
1502
|
if (typeof options.timeout !== 'undefined') {
|
|
@@ -1532,19 +1507,19 @@ function Mocha(options) {
|
|
|
1532
1507
|
this.retries(options.retries);
|
|
1533
1508
|
}
|
|
1534
1509
|
|
|
1535
|
-
if ('diff' in options) {
|
|
1536
|
-
this.hideDiff(!options.diff);
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
1510
|
[
|
|
1540
1511
|
'allowUncaught',
|
|
1541
1512
|
'asyncOnly',
|
|
1513
|
+
'bail',
|
|
1542
1514
|
'checkLeaks',
|
|
1515
|
+
'color',
|
|
1543
1516
|
'delay',
|
|
1517
|
+
'diff',
|
|
1544
1518
|
'forbidOnly',
|
|
1545
1519
|
'forbidPending',
|
|
1546
1520
|
'fullTrace',
|
|
1547
1521
|
'growl',
|
|
1522
|
+
'inlineDiffs',
|
|
1548
1523
|
'invert'
|
|
1549
1524
|
].forEach(function(opt) {
|
|
1550
1525
|
if (options[opt]) {
|
|
@@ -1557,16 +1532,13 @@ function Mocha(options) {
|
|
|
1557
1532
|
* Enables or disables bailing on the first failure.
|
|
1558
1533
|
*
|
|
1559
1534
|
* @public
|
|
1560
|
-
* @see
|
|
1535
|
+
* @see [CLI option](../#-bail-b)
|
|
1561
1536
|
* @param {boolean} [bail=true] - Whether to bail on first error.
|
|
1562
1537
|
* @returns {Mocha} this
|
|
1563
1538
|
* @chainable
|
|
1564
1539
|
*/
|
|
1565
1540
|
Mocha.prototype.bail = function(bail) {
|
|
1566
|
-
|
|
1567
|
-
bail = true;
|
|
1568
|
-
}
|
|
1569
|
-
this.suite.bail(bail);
|
|
1541
|
+
this.suite.bail(bail !== false);
|
|
1570
1542
|
return this;
|
|
1571
1543
|
};
|
|
1572
1544
|
|
|
@@ -1578,7 +1550,7 @@ Mocha.prototype.bail = function(bail) {
|
|
|
1578
1550
|
* Useful for generic setup code that must be included within test suite.
|
|
1579
1551
|
*
|
|
1580
1552
|
* @public
|
|
1581
|
-
* @see
|
|
1553
|
+
* @see [CLI option](../#-file-filedirectoryglob)
|
|
1582
1554
|
* @param {string} file - Pathname of file to be loaded.
|
|
1583
1555
|
* @returns {Mocha} this
|
|
1584
1556
|
* @chainable
|
|
@@ -1592,8 +1564,8 @@ Mocha.prototype.addFile = function(file) {
|
|
|
1592
1564
|
* Sets reporter to `reporter`, defaults to "spec".
|
|
1593
1565
|
*
|
|
1594
1566
|
* @public
|
|
1595
|
-
* @see
|
|
1596
|
-
* @see
|
|
1567
|
+
* @see [CLI option](../#-reporter-name-r-name)
|
|
1568
|
+
* @see [Reporters](../#reporters)
|
|
1597
1569
|
* @param {String|Function} reporter - Reporter name or constructor.
|
|
1598
1570
|
* @param {Object} [reporterOptions] - Options used to configure the reporter.
|
|
1599
1571
|
* @returns {Mocha} this
|
|
@@ -1651,6 +1623,8 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
|
1651
1623
|
}
|
|
1652
1624
|
this._reporter = _reporter;
|
|
1653
1625
|
}
|
|
1626
|
+
this.options.reporterOption = reporterOptions;
|
|
1627
|
+
// alias option name is used in public reporters xunit/tap/progress
|
|
1654
1628
|
this.options.reporterOptions = reporterOptions;
|
|
1655
1629
|
return this;
|
|
1656
1630
|
};
|
|
@@ -1659,8 +1633,8 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
|
1659
1633
|
* Sets test UI `name`, defaults to "bdd".
|
|
1660
1634
|
*
|
|
1661
1635
|
* @public
|
|
1662
|
-
* @see
|
|
1663
|
-
* @see
|
|
1636
|
+
* @see [CLI option](../#-ui-name-u-name)
|
|
1637
|
+
* @see [Interface DSLs](../#interfaces)
|
|
1664
1638
|
* @param {string|Function} [ui=bdd] - Interface name or class.
|
|
1665
1639
|
* @returns {Mocha} this
|
|
1666
1640
|
* @chainable
|
|
@@ -1753,8 +1727,6 @@ Mocha.unloadFile = function(file) {
|
|
|
1753
1727
|
* <strong>Intended for consumers — not used internally</strong>
|
|
1754
1728
|
*
|
|
1755
1729
|
* @public
|
|
1756
|
-
* @see {@link Mocha.unloadFile}
|
|
1757
|
-
* @see {@link Mocha#loadFiles}
|
|
1758
1730
|
* @see {@link Mocha#run}
|
|
1759
1731
|
* @returns {Mocha} this
|
|
1760
1732
|
* @chainable
|
|
@@ -1798,7 +1770,7 @@ Mocha.prototype.fgrep = function(str) {
|
|
|
1798
1770
|
* <strong>Previous filter value will be overwritten on each call!</strong>
|
|
1799
1771
|
*
|
|
1800
1772
|
* @public
|
|
1801
|
-
* @see
|
|
1773
|
+
* @see [CLI option](../#-grep-regexp-g-regexp)
|
|
1802
1774
|
* @see {@link Mocha#fgrep}
|
|
1803
1775
|
* @see {@link Mocha#invert}
|
|
1804
1776
|
* @param {RegExp|String} re - Regular expression used to select tests.
|
|
@@ -1849,32 +1821,32 @@ Mocha.prototype.invert = function() {
|
|
|
1849
1821
|
/**
|
|
1850
1822
|
* Enables or disables ignoring global leaks.
|
|
1851
1823
|
*
|
|
1824
|
+
* @deprecated since v7.0.0
|
|
1852
1825
|
* @public
|
|
1853
1826
|
* @see {@link Mocha#checkLeaks}
|
|
1854
|
-
* @param {boolean} ignoreLeaks - Whether to ignore global leaks.
|
|
1827
|
+
* @param {boolean} [ignoreLeaks=false] - Whether to ignore global leaks.
|
|
1855
1828
|
* @return {Mocha} this
|
|
1856
1829
|
* @chainable
|
|
1857
|
-
* @example
|
|
1858
|
-
*
|
|
1859
|
-
* // Ignore global leaks
|
|
1860
|
-
* mocha.ignoreLeaks(true);
|
|
1861
1830
|
*/
|
|
1862
1831
|
Mocha.prototype.ignoreLeaks = function(ignoreLeaks) {
|
|
1863
|
-
|
|
1832
|
+
utils.deprecate(
|
|
1833
|
+
'"ignoreLeaks()" is DEPRECATED, please use "checkLeaks()" instead.'
|
|
1834
|
+
);
|
|
1835
|
+
this.options.checkLeaks = !ignoreLeaks;
|
|
1864
1836
|
return this;
|
|
1865
1837
|
};
|
|
1866
1838
|
|
|
1867
1839
|
/**
|
|
1868
|
-
* Enables checking for global variables leaked while running tests.
|
|
1840
|
+
* Enables or disables checking for global variables leaked while running tests.
|
|
1869
1841
|
*
|
|
1870
1842
|
* @public
|
|
1871
|
-
* @see
|
|
1872
|
-
* @
|
|
1843
|
+
* @see [CLI option](../#-check-leaks)
|
|
1844
|
+
* @param {boolean} [checkLeaks=true] - Whether to check for global variable leaks.
|
|
1873
1845
|
* @return {Mocha} this
|
|
1874
1846
|
* @chainable
|
|
1875
1847
|
*/
|
|
1876
|
-
Mocha.prototype.checkLeaks = function() {
|
|
1877
|
-
this.options.
|
|
1848
|
+
Mocha.prototype.checkLeaks = function(checkLeaks) {
|
|
1849
|
+
this.options.checkLeaks = checkLeaks !== false;
|
|
1878
1850
|
return this;
|
|
1879
1851
|
};
|
|
1880
1852
|
|
|
@@ -1882,11 +1854,13 @@ Mocha.prototype.checkLeaks = function() {
|
|
|
1882
1854
|
* Displays full stack trace upon test failure.
|
|
1883
1855
|
*
|
|
1884
1856
|
* @public
|
|
1857
|
+
* @see [CLI option](../#-full-trace)
|
|
1858
|
+
* @param {boolean} [fullTrace=true] - Whether to print full stacktrace upon failure.
|
|
1885
1859
|
* @return {Mocha} this
|
|
1886
1860
|
* @chainable
|
|
1887
1861
|
*/
|
|
1888
|
-
Mocha.prototype.fullTrace = function() {
|
|
1889
|
-
this.options.
|
|
1862
|
+
Mocha.prototype.fullTrace = function(fullTrace) {
|
|
1863
|
+
this.options.fullTrace = fullTrace !== false;
|
|
1890
1864
|
return this;
|
|
1891
1865
|
};
|
|
1892
1866
|
|
|
@@ -1894,8 +1868,7 @@ Mocha.prototype.fullTrace = function() {
|
|
|
1894
1868
|
* Enables desktop notification support if prerequisite software installed.
|
|
1895
1869
|
*
|
|
1896
1870
|
* @public
|
|
1897
|
-
* @see
|
|
1898
|
-
* @see {@link Mocha#_growl}
|
|
1871
|
+
* @see [CLI option](../#-growl-g)
|
|
1899
1872
|
* @return {Mocha} this
|
|
1900
1873
|
* @chainable
|
|
1901
1874
|
*/
|
|
@@ -1938,65 +1911,121 @@ Mocha.prototype._growl = growl.notify;
|
|
|
1938
1911
|
* Specifies whitelist of variable names to be expected in global scope.
|
|
1939
1912
|
*
|
|
1940
1913
|
* @public
|
|
1941
|
-
* @see
|
|
1914
|
+
* @see [CLI option](../#-global-variable-name)
|
|
1942
1915
|
* @see {@link Mocha#checkLeaks}
|
|
1943
|
-
* @param {String[]|String}
|
|
1916
|
+
* @param {String[]|String} global - Accepted global variable name(s).
|
|
1944
1917
|
* @return {Mocha} this
|
|
1945
1918
|
* @chainable
|
|
1946
1919
|
* @example
|
|
1947
1920
|
*
|
|
1948
1921
|
* // Specify variables to be expected in global scope
|
|
1949
|
-
* mocha.
|
|
1922
|
+
* mocha.global(['jQuery', 'MyLib']);
|
|
1950
1923
|
*/
|
|
1951
|
-
Mocha.prototype.
|
|
1952
|
-
this.options.
|
|
1953
|
-
.concat(
|
|
1924
|
+
Mocha.prototype.global = function(global) {
|
|
1925
|
+
this.options.global = (this.options.global || [])
|
|
1926
|
+
.concat(global)
|
|
1954
1927
|
.filter(Boolean)
|
|
1955
1928
|
.filter(function(elt, idx, arr) {
|
|
1956
1929
|
return arr.indexOf(elt) === idx;
|
|
1957
1930
|
});
|
|
1958
1931
|
return this;
|
|
1959
1932
|
};
|
|
1933
|
+
// for backwards compability, 'globals' is an alias of 'global'
|
|
1934
|
+
Mocha.prototype.globals = Mocha.prototype.global;
|
|
1960
1935
|
|
|
1961
1936
|
/**
|
|
1962
1937
|
* Enables or disables TTY color output by screen-oriented reporters.
|
|
1963
1938
|
*
|
|
1939
|
+
* @deprecated since v7.0.0
|
|
1964
1940
|
* @public
|
|
1941
|
+
* @see {@link Mocha#color}
|
|
1965
1942
|
* @param {boolean} colors - Whether to enable color output.
|
|
1966
1943
|
* @return {Mocha} this
|
|
1967
1944
|
* @chainable
|
|
1968
1945
|
*/
|
|
1969
1946
|
Mocha.prototype.useColors = function(colors) {
|
|
1947
|
+
utils.deprecate('"useColors()" is DEPRECATED, please use "color()" instead.');
|
|
1970
1948
|
if (colors !== undefined) {
|
|
1971
|
-
this.options.
|
|
1949
|
+
this.options.color = colors;
|
|
1972
1950
|
}
|
|
1973
1951
|
return this;
|
|
1974
1952
|
};
|
|
1975
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* Enables or disables TTY color output by screen-oriented reporters.
|
|
1956
|
+
*
|
|
1957
|
+
* @public
|
|
1958
|
+
* @see [CLI option](../#-color-c-colors)
|
|
1959
|
+
* @param {boolean} [color=true] - Whether to enable color output.
|
|
1960
|
+
* @return {Mocha} this
|
|
1961
|
+
* @chainable
|
|
1962
|
+
*/
|
|
1963
|
+
Mocha.prototype.color = function(color) {
|
|
1964
|
+
this.options.color = color !== false;
|
|
1965
|
+
return this;
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1976
1968
|
/**
|
|
1977
1969
|
* Determines if reporter should use inline diffs (rather than +/-)
|
|
1978
1970
|
* in test failure output.
|
|
1979
1971
|
*
|
|
1972
|
+
* @deprecated since v7.0.0
|
|
1980
1973
|
* @public
|
|
1981
|
-
* @
|
|
1974
|
+
* @see {@link Mocha#inlineDiffs}
|
|
1975
|
+
* @param {boolean} [inlineDiffs=false] - Whether to use inline diffs.
|
|
1982
1976
|
* @return {Mocha} this
|
|
1983
1977
|
* @chainable
|
|
1984
1978
|
*/
|
|
1985
1979
|
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
|
|
1986
|
-
|
|
1980
|
+
utils.deprecate(
|
|
1981
|
+
'"useInlineDiffs()" is DEPRECATED, please use "inlineDiffs()" instead.'
|
|
1982
|
+
);
|
|
1983
|
+
this.options.inlineDiffs = inlineDiffs !== undefined && inlineDiffs;
|
|
1984
|
+
return this;
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* Enables or disables reporter to use inline diffs (rather than +/-)
|
|
1989
|
+
* in test failure output.
|
|
1990
|
+
*
|
|
1991
|
+
* @public
|
|
1992
|
+
* @see [CLI option](../#-inline-diffs)
|
|
1993
|
+
* @param {boolean} [inlineDiffs=true] - Whether to use inline diffs.
|
|
1994
|
+
* @return {Mocha} this
|
|
1995
|
+
* @chainable
|
|
1996
|
+
*/
|
|
1997
|
+
Mocha.prototype.inlineDiffs = function(inlineDiffs) {
|
|
1998
|
+
this.options.inlineDiffs = inlineDiffs !== false;
|
|
1987
1999
|
return this;
|
|
1988
2000
|
};
|
|
1989
2001
|
|
|
1990
2002
|
/**
|
|
1991
2003
|
* Determines if reporter should include diffs in test failure output.
|
|
1992
2004
|
*
|
|
2005
|
+
* @deprecated since v7.0.0
|
|
1993
2006
|
* @public
|
|
1994
|
-
* @
|
|
2007
|
+
* @see {@link Mocha#diff}
|
|
2008
|
+
* @param {boolean} [hideDiff=false] - Whether to hide diffs.
|
|
1995
2009
|
* @return {Mocha} this
|
|
1996
2010
|
* @chainable
|
|
1997
2011
|
*/
|
|
1998
2012
|
Mocha.prototype.hideDiff = function(hideDiff) {
|
|
1999
|
-
|
|
2013
|
+
utils.deprecate('"hideDiff()" is DEPRECATED, please use "diff()" instead.');
|
|
2014
|
+
this.options.diff = !(hideDiff === true);
|
|
2015
|
+
return this;
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* Enables or disables reporter to include diff in test failure output.
|
|
2020
|
+
*
|
|
2021
|
+
* @public
|
|
2022
|
+
* @see [CLI option](../#-diff)
|
|
2023
|
+
* @param {boolean} [diff=true] - Whether to show diff on failure.
|
|
2024
|
+
* @return {Mocha} this
|
|
2025
|
+
* @chainable
|
|
2026
|
+
*/
|
|
2027
|
+
Mocha.prototype.diff = function(diff) {
|
|
2028
|
+
this.options.diff = diff !== false;
|
|
2000
2029
|
return this;
|
|
2001
2030
|
};
|
|
2002
2031
|
|
|
@@ -2009,9 +2038,8 @@ Mocha.prototype.hideDiff = function(hideDiff) {
|
|
|
2009
2038
|
* If the value is `0`, timeouts will be disabled.
|
|
2010
2039
|
*
|
|
2011
2040
|
* @public
|
|
2012
|
-
* @see
|
|
2013
|
-
* @see
|
|
2014
|
-
* @see {@link https://mochajs.org/#timeouts|Timeouts}
|
|
2041
|
+
* @see [CLI option](../#-timeout-ms-t-ms)
|
|
2042
|
+
* @see [Timeouts](../#timeouts)
|
|
2015
2043
|
* @see {@link Mocha#enableTimeouts}
|
|
2016
2044
|
* @param {number|string} msecs - Timeout threshold value.
|
|
2017
2045
|
* @return {Mocha} this
|
|
@@ -2034,7 +2062,8 @@ Mocha.prototype.timeout = function(msecs) {
|
|
|
2034
2062
|
* Sets the number of times to retry failed tests.
|
|
2035
2063
|
*
|
|
2036
2064
|
* @public
|
|
2037
|
-
* @see
|
|
2065
|
+
* @see [CLI option](../#-retries-n)
|
|
2066
|
+
* @see [Retry Tests](../#retry-tests)
|
|
2038
2067
|
* @param {number} retry - Number of times to retry failed tests.
|
|
2039
2068
|
* @return {Mocha} this
|
|
2040
2069
|
* @chainable
|
|
@@ -2052,7 +2081,7 @@ Mocha.prototype.retries = function(n) {
|
|
|
2052
2081
|
* Sets slowness threshold value.
|
|
2053
2082
|
*
|
|
2054
2083
|
* @public
|
|
2055
|
-
* @see
|
|
2084
|
+
* @see [CLI option](../#-slow-ms-s-ms)
|
|
2056
2085
|
* @param {number} msecs - Slowness threshold value.
|
|
2057
2086
|
* @return {Mocha} this
|
|
2058
2087
|
* @chainable
|
|
@@ -2074,8 +2103,7 @@ Mocha.prototype.slow = function(msecs) {
|
|
|
2074
2103
|
* Enables or disables timeouts.
|
|
2075
2104
|
*
|
|
2076
2105
|
* @public
|
|
2077
|
-
* @see
|
|
2078
|
-
* @see {@link https://mochajs.org/#--no-timeouts|CLI option}
|
|
2106
|
+
* @see [CLI option](../#-timeout-ms-t-ms)
|
|
2079
2107
|
* @param {boolean} enableTimeouts - Whether to enable timeouts.
|
|
2080
2108
|
* @return {Mocha} this
|
|
2081
2109
|
* @chainable
|
|
@@ -2091,11 +2119,13 @@ Mocha.prototype.enableTimeouts = function(enableTimeouts) {
|
|
|
2091
2119
|
* Forces all tests to either accept a `done` callback or return a promise.
|
|
2092
2120
|
*
|
|
2093
2121
|
* @public
|
|
2122
|
+
* @see [CLI option](../#-async-only-a)
|
|
2123
|
+
* @param {boolean} [asyncOnly=true] - Wether to force `done` callback or promise.
|
|
2094
2124
|
* @return {Mocha} this
|
|
2095
2125
|
* @chainable
|
|
2096
2126
|
*/
|
|
2097
|
-
Mocha.prototype.asyncOnly = function() {
|
|
2098
|
-
this.options.asyncOnly =
|
|
2127
|
+
Mocha.prototype.asyncOnly = function(asyncOnly) {
|
|
2128
|
+
this.options.asyncOnly = asyncOnly !== false;
|
|
2099
2129
|
return this;
|
|
2100
2130
|
};
|
|
2101
2131
|
|
|
@@ -2112,14 +2142,16 @@ Mocha.prototype.noHighlighting = function() {
|
|
|
2112
2142
|
};
|
|
2113
2143
|
|
|
2114
2144
|
/**
|
|
2115
|
-
* Enables uncaught errors to propagate
|
|
2145
|
+
* Enables or disables uncaught errors to propagate.
|
|
2116
2146
|
*
|
|
2117
2147
|
* @public
|
|
2148
|
+
* @see [CLI option](../#-allow-uncaught)
|
|
2149
|
+
* @param {boolean} [allowUncaught=true] - Whether to propagate uncaught errors.
|
|
2118
2150
|
* @return {Mocha} this
|
|
2119
2151
|
* @chainable
|
|
2120
2152
|
*/
|
|
2121
|
-
Mocha.prototype.allowUncaught = function() {
|
|
2122
|
-
this.options.allowUncaught =
|
|
2153
|
+
Mocha.prototype.allowUncaught = function(allowUncaught) {
|
|
2154
|
+
this.options.allowUncaught = allowUncaught !== false;
|
|
2123
2155
|
return this;
|
|
2124
2156
|
};
|
|
2125
2157
|
|
|
@@ -2131,7 +2163,7 @@ Mocha.prototype.allowUncaught = function() {
|
|
|
2131
2163
|
* Used to perform asynch operations before any suites are run.
|
|
2132
2164
|
*
|
|
2133
2165
|
* @public
|
|
2134
|
-
* @see
|
|
2166
|
+
* @see [delayed root suite](../#delayed-root-suite)
|
|
2135
2167
|
* @returns {Mocha} this
|
|
2136
2168
|
* @chainable
|
|
2137
2169
|
*/
|
|
@@ -2144,11 +2176,13 @@ Mocha.prototype.delay = function delay() {
|
|
|
2144
2176
|
* Causes tests marked `only` to fail the suite.
|
|
2145
2177
|
*
|
|
2146
2178
|
* @public
|
|
2179
|
+
* @see [CLI option](../#-forbid-only)
|
|
2180
|
+
* @param {boolean} [forbidOnly=true] - Whether tests marked `only` fail the suite.
|
|
2147
2181
|
* @returns {Mocha} this
|
|
2148
2182
|
* @chainable
|
|
2149
2183
|
*/
|
|
2150
|
-
Mocha.prototype.forbidOnly = function() {
|
|
2151
|
-
this.options.forbidOnly =
|
|
2184
|
+
Mocha.prototype.forbidOnly = function(forbidOnly) {
|
|
2185
|
+
this.options.forbidOnly = forbidOnly !== false;
|
|
2152
2186
|
return this;
|
|
2153
2187
|
};
|
|
2154
2188
|
|
|
@@ -2156,11 +2190,13 @@ Mocha.prototype.forbidOnly = function() {
|
|
|
2156
2190
|
* Causes pending tests and tests marked `skip` to fail the suite.
|
|
2157
2191
|
*
|
|
2158
2192
|
* @public
|
|
2193
|
+
* @see [CLI option](../#-forbid-pending)
|
|
2194
|
+
* @param {boolean} [forbidPending=true] - Whether pending tests fail the suite.
|
|
2159
2195
|
* @returns {Mocha} this
|
|
2160
2196
|
* @chainable
|
|
2161
2197
|
*/
|
|
2162
|
-
Mocha.prototype.forbidPending = function() {
|
|
2163
|
-
this.options.forbidPending =
|
|
2198
|
+
Mocha.prototype.forbidPending = function(forbidPending) {
|
|
2199
|
+
this.options.forbidPending = forbidPending !== false;
|
|
2164
2200
|
return this;
|
|
2165
2201
|
};
|
|
2166
2202
|
|
|
@@ -2194,7 +2230,6 @@ Object.defineProperty(Mocha.prototype, 'version', {
|
|
|
2194
2230
|
* the cache first!
|
|
2195
2231
|
*
|
|
2196
2232
|
* @public
|
|
2197
|
-
* @see {@link Mocha#loadFiles}
|
|
2198
2233
|
* @see {@link Mocha#unloadFiles}
|
|
2199
2234
|
* @see {@link Runner#run}
|
|
2200
2235
|
* @param {DoneCB} [fn] - Callback invoked when test execution completed.
|
|
@@ -2210,8 +2245,8 @@ Mocha.prototype.run = function(fn) {
|
|
|
2210
2245
|
var runner = new exports.Runner(suite, options.delay);
|
|
2211
2246
|
createStatsCollector(runner);
|
|
2212
2247
|
var reporter = new this._reporter(runner, options);
|
|
2213
|
-
runner.
|
|
2214
|
-
runner.fullStackTrace = options.
|
|
2248
|
+
runner.checkLeaks = options.checkLeaks === true;
|
|
2249
|
+
runner.fullStackTrace = options.fullTrace;
|
|
2215
2250
|
runner.asyncOnly = options.asyncOnly;
|
|
2216
2251
|
runner.allowUncaught = options.allowUncaught;
|
|
2217
2252
|
runner.forbidOnly = options.forbidOnly;
|
|
@@ -2219,17 +2254,17 @@ Mocha.prototype.run = function(fn) {
|
|
|
2219
2254
|
if (options.grep) {
|
|
2220
2255
|
runner.grep(options.grep, options.invert);
|
|
2221
2256
|
}
|
|
2222
|
-
if (options.
|
|
2223
|
-
runner.globals(options.
|
|
2257
|
+
if (options.global) {
|
|
2258
|
+
runner.globals(options.global);
|
|
2224
2259
|
}
|
|
2225
2260
|
if (options.growl) {
|
|
2226
2261
|
this._growl(runner);
|
|
2227
2262
|
}
|
|
2228
|
-
if (options.
|
|
2229
|
-
exports.reporters.Base.useColors = options.
|
|
2263
|
+
if (options.color !== undefined) {
|
|
2264
|
+
exports.reporters.Base.useColors = options.color;
|
|
2230
2265
|
}
|
|
2231
|
-
exports.reporters.Base.inlineDiffs = options.
|
|
2232
|
-
exports.reporters.Base.hideDiff = options.
|
|
2266
|
+
exports.reporters.Base.inlineDiffs = options.inlineDiffs;
|
|
2267
|
+
exports.reporters.Base.hideDiff = !options.diff;
|
|
2233
2268
|
|
|
2234
2269
|
function done(failures) {
|
|
2235
2270
|
fn = fn || utils.noop;
|
|
@@ -2253,7 +2288,8 @@ module.exports={
|
|
|
2253
2288
|
"reporter": "spec",
|
|
2254
2289
|
"slow": 75,
|
|
2255
2290
|
"timeout": 2000,
|
|
2256
|
-
"ui": "bdd"
|
|
2291
|
+
"ui": "bdd",
|
|
2292
|
+
"watch-ignore": ["node_modules", ".git"]
|
|
2257
2293
|
}
|
|
2258
2294
|
|
|
2259
2295
|
},{}],16:[function(require,module,exports){
|
|
@@ -2428,14 +2464,14 @@ exports.cursor = {
|
|
|
2428
2464
|
}
|
|
2429
2465
|
};
|
|
2430
2466
|
|
|
2431
|
-
|
|
2467
|
+
var showDiff = (exports.showDiff = function(err) {
|
|
2432
2468
|
return (
|
|
2433
2469
|
err &&
|
|
2434
2470
|
err.showDiff !== false &&
|
|
2435
2471
|
sameType(err.actual, err.expected) &&
|
|
2436
2472
|
err.expected !== undefined
|
|
2437
2473
|
);
|
|
2438
|
-
}
|
|
2474
|
+
});
|
|
2439
2475
|
|
|
2440
2476
|
function stringifyDiffObjs(err) {
|
|
2441
2477
|
if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
|
|
@@ -2456,9 +2492,19 @@ function stringifyDiffObjs(err) {
|
|
|
2456
2492
|
* @return {string} Diff
|
|
2457
2493
|
*/
|
|
2458
2494
|
var generateDiff = (exports.generateDiff = function(actual, expected) {
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2495
|
+
try {
|
|
2496
|
+
return exports.inlineDiffs
|
|
2497
|
+
? inlineDiff(actual, expected)
|
|
2498
|
+
: unifiedDiff(actual, expected);
|
|
2499
|
+
} catch (err) {
|
|
2500
|
+
var msg =
|
|
2501
|
+
'\n ' +
|
|
2502
|
+
color('diff added', '+ expected') +
|
|
2503
|
+
' ' +
|
|
2504
|
+
color('diff removed', '- actual: failed to generate Mocha diff') +
|
|
2505
|
+
'\n';
|
|
2506
|
+
return msg;
|
|
2507
|
+
}
|
|
2462
2508
|
});
|
|
2463
2509
|
|
|
2464
2510
|
/**
|
|
@@ -2471,6 +2517,7 @@ var generateDiff = (exports.generateDiff = function(actual, expected) {
|
|
|
2471
2517
|
* Error property
|
|
2472
2518
|
*/
|
|
2473
2519
|
exports.list = function(failures) {
|
|
2520
|
+
var multipleErr, multipleTest;
|
|
2474
2521
|
Base.consoleLog();
|
|
2475
2522
|
failures.forEach(function(test, i) {
|
|
2476
2523
|
// format
|
|
@@ -2481,7 +2528,16 @@ exports.list = function(failures) {
|
|
|
2481
2528
|
|
|
2482
2529
|
// msg
|
|
2483
2530
|
var msg;
|
|
2484
|
-
var err
|
|
2531
|
+
var err;
|
|
2532
|
+
if (test.err && test.err.multiple) {
|
|
2533
|
+
if (multipleTest !== test) {
|
|
2534
|
+
multipleTest = test;
|
|
2535
|
+
multipleErr = [test.err].concat(test.err.multiple);
|
|
2536
|
+
}
|
|
2537
|
+
err = multipleErr.shift();
|
|
2538
|
+
} else {
|
|
2539
|
+
err = test.err;
|
|
2540
|
+
}
|
|
2485
2541
|
var message;
|
|
2486
2542
|
if (err.message && typeof err.message.toString === 'function') {
|
|
2487
2543
|
message = err.message + '';
|
|
@@ -2572,7 +2628,12 @@ function Base(runner, options) {
|
|
|
2572
2628
|
if (showDiff(err)) {
|
|
2573
2629
|
stringifyDiffObjs(err);
|
|
2574
2630
|
}
|
|
2575
|
-
|
|
2631
|
+
// more than one error per test
|
|
2632
|
+
if (test.err && err instanceof Error) {
|
|
2633
|
+
test.err.multiple = (test.err.multiple || []).concat(err);
|
|
2634
|
+
} else {
|
|
2635
|
+
test.err = err;
|
|
2636
|
+
}
|
|
2576
2637
|
failures.push(test);
|
|
2577
2638
|
});
|
|
2578
2639
|
}
|
|
@@ -2581,7 +2642,7 @@ function Base(runner, options) {
|
|
|
2581
2642
|
* Outputs common epilogue used by many of the bundled reporters.
|
|
2582
2643
|
*
|
|
2583
2644
|
* @public
|
|
2584
|
-
* @memberof Mocha.reporters
|
|
2645
|
+
* @memberof Mocha.reporters
|
|
2585
2646
|
*/
|
|
2586
2647
|
Base.prototype.epilogue = function() {
|
|
2587
2648
|
var stats = this.stats;
|
|
@@ -3309,8 +3370,8 @@ function hideSuitesWithout(classname) {
|
|
|
3309
3370
|
*/
|
|
3310
3371
|
function unhide() {
|
|
3311
3372
|
var els = document.getElementsByClassName('suite hidden');
|
|
3312
|
-
|
|
3313
|
-
els[
|
|
3373
|
+
while (els.length > 0) {
|
|
3374
|
+
els[0].className = els[0].className.replace('suite hidden', 'suite');
|
|
3314
3375
|
}
|
|
3315
3376
|
}
|
|
3316
3377
|
|
|
@@ -4916,9 +4977,9 @@ XUnit.prototype.test = function(test) {
|
|
|
4916
4977
|
if (test.state === STATE_FAILED) {
|
|
4917
4978
|
var err = test.err;
|
|
4918
4979
|
var diff =
|
|
4919
|
-
Base.hideDiff
|
|
4920
|
-
? ''
|
|
4921
|
-
: '
|
|
4980
|
+
!Base.hideDiff && Base.showDiff(err)
|
|
4981
|
+
? '\n' + Base.generateDiff(err.actual, err.expected)
|
|
4982
|
+
: '';
|
|
4922
4983
|
this.write(
|
|
4923
4984
|
tag(
|
|
4924
4985
|
'testcase',
|
|
@@ -5108,7 +5169,8 @@ Runnable.prototype.enableTimeouts = function(enabled) {
|
|
|
5108
5169
|
* @public
|
|
5109
5170
|
*/
|
|
5110
5171
|
Runnable.prototype.skip = function() {
|
|
5111
|
-
|
|
5172
|
+
this.pending = true;
|
|
5173
|
+
throw new Pending('sync skip; aborting execution');
|
|
5112
5174
|
};
|
|
5113
5175
|
|
|
5114
5176
|
/**
|
|
@@ -5316,34 +5378,27 @@ Runnable.prototype.run = function(fn) {
|
|
|
5316
5378
|
|
|
5317
5379
|
// allows skip() to be used in an explicit async context
|
|
5318
5380
|
this.skip = function asyncSkip() {
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
//
|
|
5322
|
-
// the failure.
|
|
5381
|
+
this.pending = true;
|
|
5382
|
+
done();
|
|
5383
|
+
// halt execution, the uncaught handler will ignore the failure.
|
|
5323
5384
|
throw new Pending('async skip; aborting execution');
|
|
5324
5385
|
};
|
|
5325
5386
|
|
|
5326
|
-
if (this.allowUncaught) {
|
|
5327
|
-
return callFnAsync(this.fn);
|
|
5328
|
-
}
|
|
5329
5387
|
try {
|
|
5330
5388
|
callFnAsync(this.fn);
|
|
5331
5389
|
} catch (err) {
|
|
5390
|
+
// handles async runnables which actually run synchronously
|
|
5332
5391
|
emitted = true;
|
|
5392
|
+
if (err instanceof Pending) {
|
|
5393
|
+
return; // done() is already called in this.skip()
|
|
5394
|
+
} else if (this.allowUncaught) {
|
|
5395
|
+
throw err;
|
|
5396
|
+
}
|
|
5333
5397
|
done(Runnable.toValueOrError(err));
|
|
5334
5398
|
}
|
|
5335
5399
|
return;
|
|
5336
5400
|
}
|
|
5337
5401
|
|
|
5338
|
-
if (this.allowUncaught) {
|
|
5339
|
-
if (this.isPending()) {
|
|
5340
|
-
done();
|
|
5341
|
-
} else {
|
|
5342
|
-
callFn(this.fn);
|
|
5343
|
-
}
|
|
5344
|
-
return;
|
|
5345
|
-
}
|
|
5346
|
-
|
|
5347
5402
|
// sync or promise-returning
|
|
5348
5403
|
try {
|
|
5349
5404
|
if (this.isPending()) {
|
|
@@ -5353,6 +5408,11 @@ Runnable.prototype.run = function(fn) {
|
|
|
5353
5408
|
}
|
|
5354
5409
|
} catch (err) {
|
|
5355
5410
|
emitted = true;
|
|
5411
|
+
if (err instanceof Pending) {
|
|
5412
|
+
return done();
|
|
5413
|
+
} else if (this.allowUncaught) {
|
|
5414
|
+
throw err;
|
|
5415
|
+
}
|
|
5356
5416
|
done(Runnable.toValueOrError(err));
|
|
5357
5417
|
}
|
|
5358
5418
|
|
|
@@ -5497,8 +5557,9 @@ var sQuote = utils.sQuote;
|
|
|
5497
5557
|
var stackFilter = utils.stackTraceFilter();
|
|
5498
5558
|
var stringify = utils.stringify;
|
|
5499
5559
|
var type = utils.type;
|
|
5500
|
-
var
|
|
5501
|
-
|
|
5560
|
+
var errors = require('./errors');
|
|
5561
|
+
var createInvalidExceptionError = errors.createInvalidExceptionError;
|
|
5562
|
+
var createUnsupportedError = errors.createUnsupportedError;
|
|
5502
5563
|
|
|
5503
5564
|
/**
|
|
5504
5565
|
* Non-enumerable globals.
|
|
@@ -5717,7 +5778,7 @@ Runner.prototype.globals = function(arr) {
|
|
|
5717
5778
|
* @private
|
|
5718
5779
|
*/
|
|
5719
5780
|
Runner.prototype.checkGlobals = function(test) {
|
|
5720
|
-
if (this.
|
|
5781
|
+
if (!this.checkLeaks) {
|
|
5721
5782
|
return;
|
|
5722
5783
|
}
|
|
5723
5784
|
var ok = this._globals;
|
|
@@ -5788,8 +5849,7 @@ Runner.prototype.fail = function(test, err) {
|
|
|
5788
5849
|
* - Failed `before each` hook skips remaining tests in a
|
|
5789
5850
|
* suite and jumps to corresponding `after each` hook,
|
|
5790
5851
|
* which is run only once
|
|
5791
|
-
* - Failed `after` hook does not alter
|
|
5792
|
-
* execution order
|
|
5852
|
+
* - Failed `after` hook does not alter execution order
|
|
5793
5853
|
* - Failed `after each` hook skips remaining tests in a
|
|
5794
5854
|
* suite and subsuites, but executes other `after each`
|
|
5795
5855
|
* hooks
|
|
@@ -5859,34 +5919,37 @@ Runner.prototype.hook = function(name, fn) {
|
|
|
5859
5919
|
if (testError) {
|
|
5860
5920
|
self.fail(self.test, testError);
|
|
5861
5921
|
}
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
);
|
|
5922
|
+
// conditional skip
|
|
5923
|
+
if (hook.pending) {
|
|
5924
|
+
if (name === HOOK_TYPE_AFTER_EACH) {
|
|
5925
|
+
// TODO define and implement use case
|
|
5926
|
+
if (self.test) {
|
|
5927
|
+
self.test.pending = true;
|
|
5869
5928
|
}
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
}
|
|
5874
|
-
} else {
|
|
5875
|
-
suite.tests.forEach(function(test) {
|
|
5876
|
-
test.pending = true;
|
|
5877
|
-
});
|
|
5878
|
-
suite.suites.forEach(function(suite) {
|
|
5879
|
-
suite.pending = true;
|
|
5880
|
-
});
|
|
5881
|
-
// a pending hook won't be executed twice.
|
|
5882
|
-
hook.pending = true;
|
|
5929
|
+
} else if (name === HOOK_TYPE_BEFORE_EACH) {
|
|
5930
|
+
if (self.test) {
|
|
5931
|
+
self.test.pending = true;
|
|
5883
5932
|
}
|
|
5933
|
+
self.emit(constants.EVENT_HOOK_END, hook);
|
|
5934
|
+
hook.pending = false; // activates hook for next test
|
|
5935
|
+
return fn(new Error('abort hookDown'));
|
|
5936
|
+
} else if (name === HOOK_TYPE_BEFORE_ALL) {
|
|
5937
|
+
suite.tests.forEach(function(test) {
|
|
5938
|
+
test.pending = true;
|
|
5939
|
+
});
|
|
5940
|
+
suite.suites.forEach(function(suite) {
|
|
5941
|
+
suite.pending = true;
|
|
5942
|
+
});
|
|
5884
5943
|
} else {
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
return fn(
|
|
5944
|
+
hook.pending = false;
|
|
5945
|
+
var errForbid = createUnsupportedError('`this.skip` forbidden');
|
|
5946
|
+
self.failHook(hook, errForbid);
|
|
5947
|
+
return fn(errForbid);
|
|
5889
5948
|
}
|
|
5949
|
+
} else if (err) {
|
|
5950
|
+
self.failHook(hook, err);
|
|
5951
|
+
// stop executing hooks, notify callee of hook err
|
|
5952
|
+
return fn(err);
|
|
5890
5953
|
}
|
|
5891
5954
|
self.emit(constants.EVENT_HOOK_END, hook);
|
|
5892
5955
|
delete hook.ctx.currentTest;
|
|
@@ -5998,6 +6061,9 @@ Runner.prototype.runTest = function(fn) {
|
|
|
5998
6061
|
test.asyncOnly = true;
|
|
5999
6062
|
}
|
|
6000
6063
|
test.on('error', function(err) {
|
|
6064
|
+
if (err instanceof Pending) {
|
|
6065
|
+
return;
|
|
6066
|
+
}
|
|
6001
6067
|
self.fail(test, err);
|
|
6002
6068
|
});
|
|
6003
6069
|
if (this.allowUncaught) {
|
|
@@ -6093,6 +6159,7 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6093
6159
|
return;
|
|
6094
6160
|
}
|
|
6095
6161
|
|
|
6162
|
+
// static skip, no hooks are executed
|
|
6096
6163
|
if (test.isPending()) {
|
|
6097
6164
|
if (self.forbidPending) {
|
|
6098
6165
|
test.isPending = alwaysFalse;
|
|
@@ -6108,6 +6175,7 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6108
6175
|
// execute test and hook(s)
|
|
6109
6176
|
self.emit(constants.EVENT_TEST_BEGIN, (self.test = test));
|
|
6110
6177
|
self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) {
|
|
6178
|
+
// conditional skip within beforeEach
|
|
6111
6179
|
if (test.isPending()) {
|
|
6112
6180
|
if (self.forbidPending) {
|
|
6113
6181
|
test.isPending = alwaysFalse;
|
|
@@ -6117,7 +6185,13 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6117
6185
|
self.emit(constants.EVENT_TEST_PENDING, test);
|
|
6118
6186
|
}
|
|
6119
6187
|
self.emit(constants.EVENT_TEST_END, test);
|
|
6120
|
-
|
|
6188
|
+
// skip inner afterEach hooks below errSuite level
|
|
6189
|
+
var origSuite = self.suite;
|
|
6190
|
+
self.suite = errSuite;
|
|
6191
|
+
return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) {
|
|
6192
|
+
self.suite = origSuite;
|
|
6193
|
+
next(e, eSuite);
|
|
6194
|
+
});
|
|
6121
6195
|
}
|
|
6122
6196
|
if (err) {
|
|
6123
6197
|
return hookErr(err, errSuite, false);
|
|
@@ -6125,14 +6199,20 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6125
6199
|
self.currentRunnable = self.test;
|
|
6126
6200
|
self.runTest(function(err) {
|
|
6127
6201
|
test = self.test;
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
if (
|
|
6202
|
+
// conditional skip within it
|
|
6203
|
+
if (test.pending) {
|
|
6204
|
+
if (self.forbidPending) {
|
|
6205
|
+
test.isPending = alwaysFalse;
|
|
6131
6206
|
self.fail(test, new Error('Pending test forbidden'));
|
|
6132
|
-
|
|
6133
|
-
|
|
6207
|
+
delete test.isPending;
|
|
6208
|
+
} else {
|
|
6134
6209
|
self.emit(constants.EVENT_TEST_PENDING, test);
|
|
6135
|
-
}
|
|
6210
|
+
}
|
|
6211
|
+
self.emit(constants.EVENT_TEST_END, test);
|
|
6212
|
+
return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
|
|
6213
|
+
} else if (err) {
|
|
6214
|
+
var retry = test.currentRetry();
|
|
6215
|
+
if (retry < test.retries()) {
|
|
6136
6216
|
var clonedTest = test.clone();
|
|
6137
6217
|
clonedTest.currentRetry(retry + 1);
|
|
6138
6218
|
tests.unshift(clonedTest);
|
|
@@ -6146,11 +6226,6 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6146
6226
|
self.fail(test, err);
|
|
6147
6227
|
}
|
|
6148
6228
|
self.emit(constants.EVENT_TEST_END, test);
|
|
6149
|
-
|
|
6150
|
-
if (err instanceof Pending) {
|
|
6151
|
-
return next();
|
|
6152
|
-
}
|
|
6153
|
-
|
|
6154
6229
|
return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
|
|
6155
6230
|
}
|
|
6156
6231
|
|
|
@@ -6267,6 +6342,10 @@ Runner.prototype.uncaught = function(err) {
|
|
|
6267
6342
|
if (err instanceof Pending) {
|
|
6268
6343
|
return;
|
|
6269
6344
|
}
|
|
6345
|
+
if (this.allowUncaught) {
|
|
6346
|
+
throw err;
|
|
6347
|
+
}
|
|
6348
|
+
|
|
6270
6349
|
if (err) {
|
|
6271
6350
|
debug('uncaught exception %O', err);
|
|
6272
6351
|
} else {
|
|
@@ -6302,11 +6381,17 @@ Runner.prototype.uncaught = function(err) {
|
|
|
6302
6381
|
|
|
6303
6382
|
runnable.clearTimeout();
|
|
6304
6383
|
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6384
|
+
if (runnable.isFailed()) {
|
|
6385
|
+
// Ignore error if already failed
|
|
6386
|
+
return;
|
|
6387
|
+
} else if (runnable.isPending()) {
|
|
6388
|
+
// report 'pending test' retrospectively as failed
|
|
6389
|
+
runnable.isPending = alwaysFalse;
|
|
6390
|
+
this.fail(runnable, err);
|
|
6391
|
+
delete runnable.isPending;
|
|
6308
6392
|
return;
|
|
6309
6393
|
}
|
|
6394
|
+
|
|
6310
6395
|
// we cannot recover gracefully if a Runnable has already passed
|
|
6311
6396
|
// then fails asynchronously
|
|
6312
6397
|
var alreadyPassed = runnable.isPassed();
|
|
@@ -6338,7 +6423,7 @@ Runner.prototype.uncaught = function(err) {
|
|
|
6338
6423
|
}
|
|
6339
6424
|
|
|
6340
6425
|
// bail
|
|
6341
|
-
this.
|
|
6426
|
+
this.abort();
|
|
6342
6427
|
};
|
|
6343
6428
|
|
|
6344
6429
|
/**
|
|
@@ -6388,6 +6473,12 @@ Runner.prototype.run = function(fn) {
|
|
|
6388
6473
|
this.on(constants.EVENT_RUN_END, function() {
|
|
6389
6474
|
debug(constants.EVENT_RUN_END);
|
|
6390
6475
|
process.removeListener('uncaughtException', uncaught);
|
|
6476
|
+
process.on('uncaughtException', function(err) {
|
|
6477
|
+
if (err instanceof Pending) {
|
|
6478
|
+
return;
|
|
6479
|
+
}
|
|
6480
|
+
throw err;
|
|
6481
|
+
});
|
|
6391
6482
|
fn(self.failures);
|
|
6392
6483
|
});
|
|
6393
6484
|
|
|
@@ -7339,80 +7430,6 @@ exports.isString = function(obj) {
|
|
|
7339
7430
|
return typeof obj === 'string';
|
|
7340
7431
|
};
|
|
7341
7432
|
|
|
7342
|
-
/**
|
|
7343
|
-
* Watch the given `files` for changes
|
|
7344
|
-
* and invoke `fn(file)` on modification.
|
|
7345
|
-
*
|
|
7346
|
-
* @private
|
|
7347
|
-
* @param {Array} files
|
|
7348
|
-
* @param {Function} fn
|
|
7349
|
-
*/
|
|
7350
|
-
exports.watch = function(files, fn) {
|
|
7351
|
-
var options = {interval: 100};
|
|
7352
|
-
var debug = require('debug')('mocha:watch');
|
|
7353
|
-
files.forEach(function(file) {
|
|
7354
|
-
debug('file %s', file);
|
|
7355
|
-
fs.watchFile(file, options, function(curr, prev) {
|
|
7356
|
-
if (prev.mtime < curr.mtime) {
|
|
7357
|
-
fn(file);
|
|
7358
|
-
}
|
|
7359
|
-
});
|
|
7360
|
-
});
|
|
7361
|
-
};
|
|
7362
|
-
|
|
7363
|
-
/**
|
|
7364
|
-
* Predicate to screen `pathname` for further consideration.
|
|
7365
|
-
*
|
|
7366
|
-
* @description
|
|
7367
|
-
* Returns <code>false</code> for pathname referencing:
|
|
7368
|
-
* <ul>
|
|
7369
|
-
* <li>'npm' package installation directory
|
|
7370
|
-
* <li>'git' version control directory
|
|
7371
|
-
* </ul>
|
|
7372
|
-
*
|
|
7373
|
-
* @private
|
|
7374
|
-
* @param {string} pathname - File or directory name to screen
|
|
7375
|
-
* @return {boolean} whether pathname should be further considered
|
|
7376
|
-
* @example
|
|
7377
|
-
* ['node_modules', 'test.js'].filter(considerFurther); // => ['test.js']
|
|
7378
|
-
*/
|
|
7379
|
-
function considerFurther(pathname) {
|
|
7380
|
-
var ignore = ['node_modules', '.git'];
|
|
7381
|
-
|
|
7382
|
-
return !~ignore.indexOf(pathname);
|
|
7383
|
-
}
|
|
7384
|
-
|
|
7385
|
-
/**
|
|
7386
|
-
* Lookup files in the given `dir`.
|
|
7387
|
-
*
|
|
7388
|
-
* @description
|
|
7389
|
-
* Filenames are returned in _traversal_ order by the OS/filesystem.
|
|
7390
|
-
* **Make no assumption that the names will be sorted in any fashion.**
|
|
7391
|
-
*
|
|
7392
|
-
* @private
|
|
7393
|
-
* @param {string} dir
|
|
7394
|
-
* @param {string[]} [exts=['js']]
|
|
7395
|
-
* @param {Array} [ret=[]]
|
|
7396
|
-
* @return {Array}
|
|
7397
|
-
*/
|
|
7398
|
-
exports.files = function(dir, exts, ret) {
|
|
7399
|
-
ret = ret || [];
|
|
7400
|
-
exts = exts || ['js'];
|
|
7401
|
-
|
|
7402
|
-
fs.readdirSync(dir)
|
|
7403
|
-
.filter(considerFurther)
|
|
7404
|
-
.forEach(function(dirent) {
|
|
7405
|
-
var pathname = path.join(dir, dirent);
|
|
7406
|
-
if (fs.lstatSync(pathname).isDirectory()) {
|
|
7407
|
-
exports.files(pathname, exts, ret);
|
|
7408
|
-
} else if (hasMatchingExtname(pathname, exts)) {
|
|
7409
|
-
ret.push(pathname);
|
|
7410
|
-
}
|
|
7411
|
-
});
|
|
7412
|
-
|
|
7413
|
-
return ret;
|
|
7414
|
-
};
|
|
7415
|
-
|
|
7416
7433
|
/**
|
|
7417
7434
|
* Compute a slug from the given `str`.
|
|
7418
7435
|
*
|
|
@@ -8193,7 +8210,7 @@ exports.defineConstants = function(obj) {
|
|
|
8193
8210
|
};
|
|
8194
8211
|
|
|
8195
8212
|
}).call(this,require('_process'),require("buffer").Buffer)
|
|
8196
|
-
},{"./errors":6,"_process":69,"buffer":43,"
|
|
8213
|
+
},{"./errors":6,"_process":69,"buffer":43,"fs":42,"glob":42,"he":54,"object.assign":65,"path":42,"util":89}],39:[function(require,module,exports){
|
|
8197
8214
|
'use strict'
|
|
8198
8215
|
|
|
8199
8216
|
exports.byteLength = byteLength
|
|
@@ -18073,7 +18090,7 @@ function hasOwnProperty(obj, prop) {
|
|
|
18073
18090
|
},{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
|
|
18074
18091
|
module.exports={
|
|
18075
18092
|
"name": "mocha",
|
|
18076
|
-
"version": "
|
|
18093
|
+
"version": "7.0.0",
|
|
18077
18094
|
"homepage": "https://mochajs.org/",
|
|
18078
18095
|
"notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
|
|
18079
18096
|
}
|