mocha 1.2.1 → 1.3.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/.npmignore +2 -0
- package/.travis.yml +1 -1
- package/History.md +38 -0
- package/Makefile +9 -2
- package/_mocha.js +160 -63
- package/bin/_mocha +66 -61
- package/bin/mocha +5 -1
- package/lib/interfaces/bdd.js +23 -6
- package/lib/mocha.js +55 -10
- package/lib/reporters/base.js +5 -5
- package/lib/reporters/dot.js +5 -4
- package/lib/reporters/html.js +28 -13
- package/lib/reporters/index.js +3 -2
- package/lib/reporters/landing.js +2 -2
- package/lib/reporters/min.js +3 -2
- package/lib/reporters/nyan.js +6 -6
- package/lib/reporters/progress.js +1 -1
- package/lib/reporters/xunit.js +5 -1
- package/lib/runnable.js +4 -4
- package/lib/runner.js +12 -6
- package/lib/suite.js +7 -1
- package/lib/utils.js +1 -1
- package/mocha.css +18 -1
- package/mocha.js +160 -63
- package/my-reporter.js +23 -0
- package/package.json +2 -2
- package/test.js +5 -11
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/info.plist +0 -19
- package/support/compile.js +0 -154
- package/support/foot.js +0 -1
- package/support/head.js +0 -2
- package/support/tail.js +0 -150
- package/support/template.html +0 -16
package/mocha.js
CHANGED
|
@@ -537,11 +537,6 @@ module.exports = function(suite){
|
|
|
537
537
|
|
|
538
538
|
suite.on('pre-require', function(context){
|
|
539
539
|
|
|
540
|
-
// noop variants
|
|
541
|
-
|
|
542
|
-
context.xdescribe = function(){};
|
|
543
|
-
context.xit = function(){};
|
|
544
|
-
|
|
545
540
|
/**
|
|
546
541
|
* Execute before running tests.
|
|
547
542
|
*/
|
|
@@ -574,6 +569,18 @@ module.exports = function(suite){
|
|
|
574
569
|
suites[0].afterEach(fn);
|
|
575
570
|
};
|
|
576
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Pending describe.
|
|
574
|
+
*/
|
|
575
|
+
|
|
576
|
+
context.xdescribe = context.xcontext = function(title, fn){
|
|
577
|
+
var suite = Suite.create(suites[0], title);
|
|
578
|
+
suite.pending = true;
|
|
579
|
+
suites.unshift(suite);
|
|
580
|
+
fn();
|
|
581
|
+
suites.shift();
|
|
582
|
+
};
|
|
583
|
+
|
|
577
584
|
/**
|
|
578
585
|
* Describe a "suite" with the given `title`
|
|
579
586
|
* and callback `fn` containing nested suites
|
|
@@ -594,7 +601,17 @@ module.exports = function(suite){
|
|
|
594
601
|
*/
|
|
595
602
|
|
|
596
603
|
context.it = context.specify = function(title, fn){
|
|
597
|
-
suites[0]
|
|
604
|
+
var suite = suites[0];
|
|
605
|
+
if (suite.pending) var fn = null;
|
|
606
|
+
suite.addTest(new Test(title, fn));
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Pending test case.
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
context.xit = context.xspecify = function(title){
|
|
614
|
+
context.it(title);
|
|
598
615
|
};
|
|
599
616
|
});
|
|
600
617
|
};
|
|
@@ -885,12 +902,6 @@ var path = require('browser/path');
|
|
|
885
902
|
|
|
886
903
|
exports = module.exports = Mocha;
|
|
887
904
|
|
|
888
|
-
/**
|
|
889
|
-
* Library version.
|
|
890
|
-
*/
|
|
891
|
-
|
|
892
|
-
exports.version = '1.2.1';
|
|
893
|
-
|
|
894
905
|
/**
|
|
895
906
|
* Expose internals.
|
|
896
907
|
*/
|
|
@@ -991,13 +1002,15 @@ Mocha.prototype.ui = function(name){
|
|
|
991
1002
|
* @api private
|
|
992
1003
|
*/
|
|
993
1004
|
|
|
994
|
-
Mocha.prototype.loadFiles = function(){
|
|
1005
|
+
Mocha.prototype.loadFiles = function(fn){
|
|
995
1006
|
var suite = this.suite;
|
|
1007
|
+
var pending = this.files.length;
|
|
996
1008
|
this.files.forEach(function(file){
|
|
997
1009
|
file = path.resolve(file);
|
|
998
1010
|
suite.emit('pre-require', global, file);
|
|
999
1011
|
suite.emit('require', require(file), file);
|
|
1000
1012
|
suite.emit('post-require', global, file);
|
|
1013
|
+
--pending || (fn && fn());
|
|
1001
1014
|
});
|
|
1002
1015
|
};
|
|
1003
1016
|
|
|
@@ -1007,7 +1020,7 @@ Mocha.prototype.loadFiles = function(){
|
|
|
1007
1020
|
* @api private
|
|
1008
1021
|
*/
|
|
1009
1022
|
|
|
1010
|
-
Mocha.prototype.
|
|
1023
|
+
Mocha.prototype._growl = function(runner, reporter) {
|
|
1011
1024
|
var notify = require('growl');
|
|
1012
1025
|
|
|
1013
1026
|
runner.on('end', function(){
|
|
@@ -1040,6 +1053,55 @@ Mocha.prototype.grep = function(re){
|
|
|
1040
1053
|
return this;
|
|
1041
1054
|
};
|
|
1042
1055
|
|
|
1056
|
+
/**
|
|
1057
|
+
* Invert `.grep()` matches.
|
|
1058
|
+
*
|
|
1059
|
+
* @return {Mocha}
|
|
1060
|
+
* @api public
|
|
1061
|
+
*/
|
|
1062
|
+
|
|
1063
|
+
Mocha.prototype.invert = function(){
|
|
1064
|
+
this.options.invert = true;
|
|
1065
|
+
return this;
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Ignore global leaks.
|
|
1070
|
+
*
|
|
1071
|
+
* @return {Mocha}
|
|
1072
|
+
* @api public
|
|
1073
|
+
*/
|
|
1074
|
+
|
|
1075
|
+
Mocha.prototype.ignoreLeaks = function(){
|
|
1076
|
+
this.options.ignoreLeaks = true;
|
|
1077
|
+
return this;
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Enable growl support.
|
|
1082
|
+
*
|
|
1083
|
+
* @return {Mocha}
|
|
1084
|
+
* @api public
|
|
1085
|
+
*/
|
|
1086
|
+
|
|
1087
|
+
Mocha.prototype.growl = function(){
|
|
1088
|
+
this.options.growl = true;
|
|
1089
|
+
return this;
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Ignore `globals`.
|
|
1094
|
+
*
|
|
1095
|
+
* @param {Array} globals
|
|
1096
|
+
* @return {Mocha}
|
|
1097
|
+
* @api public
|
|
1098
|
+
*/
|
|
1099
|
+
|
|
1100
|
+
Mocha.prototype.globals = function(globals){
|
|
1101
|
+
this.options.globals = globals;
|
|
1102
|
+
return this;
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1043
1105
|
/**
|
|
1044
1106
|
* Run tests and invoke `fn()` when complete.
|
|
1045
1107
|
*
|
|
@@ -1055,9 +1117,9 @@ Mocha.prototype.run = function(fn){
|
|
|
1055
1117
|
var runner = new exports.Runner(suite);
|
|
1056
1118
|
var reporter = new this._reporter(runner);
|
|
1057
1119
|
runner.ignoreLeaks = options.ignoreLeaks;
|
|
1058
|
-
if (options.grep) runner.grep(options.grep);
|
|
1120
|
+
if (options.grep) runner.grep(options.grep, options.invert);
|
|
1059
1121
|
if (options.globals) runner.globals(options.globals);
|
|
1060
|
-
if (options.growl) this.
|
|
1122
|
+
if (options.growl) this._growl(runner, reporter);
|
|
1061
1123
|
return runner.run(fn);
|
|
1062
1124
|
};
|
|
1063
1125
|
|
|
@@ -1140,7 +1202,7 @@ exports.colors = {
|
|
|
1140
1202
|
|
|
1141
1203
|
var color = exports.color = function(type, str) {
|
|
1142
1204
|
if (!exports.useColors) return str;
|
|
1143
|
-
return '\
|
|
1205
|
+
return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
|
|
1144
1206
|
};
|
|
1145
1207
|
|
|
1146
1208
|
/**
|
|
@@ -1163,19 +1225,19 @@ exports.window = {
|
|
|
1163
1225
|
|
|
1164
1226
|
exports.cursor = {
|
|
1165
1227
|
hide: function(){
|
|
1166
|
-
process.stdout.write('\
|
|
1228
|
+
process.stdout.write('\u001b[?25l');
|
|
1167
1229
|
},
|
|
1168
1230
|
|
|
1169
1231
|
show: function(){
|
|
1170
|
-
process.stdout.write('\
|
|
1232
|
+
process.stdout.write('\u001b[?25h');
|
|
1171
1233
|
},
|
|
1172
1234
|
|
|
1173
1235
|
deleteLine: function(){
|
|
1174
|
-
process.stdout.write('\
|
|
1236
|
+
process.stdout.write('\u001b[2K');
|
|
1175
1237
|
},
|
|
1176
1238
|
|
|
1177
1239
|
beginningOfLine: function(){
|
|
1178
|
-
process.stdout.write('\
|
|
1240
|
+
process.stdout.write('\u001b[0G');
|
|
1179
1241
|
},
|
|
1180
1242
|
|
|
1181
1243
|
CR: function(){
|
|
@@ -1510,6 +1572,7 @@ function Dot(runner) {
|
|
|
1510
1572
|
var self = this
|
|
1511
1573
|
, stats = this.stats
|
|
1512
1574
|
, width = Base.window.width * .75 | 0
|
|
1575
|
+
, c = '․'
|
|
1513
1576
|
, n = 0;
|
|
1514
1577
|
|
|
1515
1578
|
runner.on('start', function(){
|
|
@@ -1517,21 +1580,21 @@ function Dot(runner) {
|
|
|
1517
1580
|
});
|
|
1518
1581
|
|
|
1519
1582
|
runner.on('pending', function(test){
|
|
1520
|
-
process.stdout.write(color('pending',
|
|
1583
|
+
process.stdout.write(color('pending', c));
|
|
1521
1584
|
});
|
|
1522
1585
|
|
|
1523
1586
|
runner.on('pass', function(test){
|
|
1524
1587
|
if (++n % width == 0) process.stdout.write('\n ');
|
|
1525
1588
|
if ('slow' == test.speed) {
|
|
1526
|
-
process.stdout.write(color('bright yellow',
|
|
1589
|
+
process.stdout.write(color('bright yellow', c));
|
|
1527
1590
|
} else {
|
|
1528
|
-
process.stdout.write(color(test.speed,
|
|
1591
|
+
process.stdout.write(color(test.speed, c));
|
|
1529
1592
|
}
|
|
1530
1593
|
});
|
|
1531
1594
|
|
|
1532
1595
|
runner.on('fail', function(test, err){
|
|
1533
1596
|
if (++n % width == 0) process.stdout.write('\n ');
|
|
1534
|
-
process.stdout.write(color('fail',
|
|
1597
|
+
process.stdout.write(color('fail', c));
|
|
1535
1598
|
});
|
|
1536
1599
|
|
|
1537
1600
|
runner.on('end', function(){
|
|
@@ -1636,8 +1699,8 @@ exports = module.exports = HTML;
|
|
|
1636
1699
|
|
|
1637
1700
|
var statsTemplate = '<ul id="stats">'
|
|
1638
1701
|
+ '<li class="progress"><canvas width="40" height="40"></canvas></li>'
|
|
1639
|
-
+ '<li class="passes">passes
|
|
1640
|
-
+ '<li class="failures">failures
|
|
1702
|
+
+ '<li class="passes"><a href="#">passes:</a> <em>0</em></li>'
|
|
1703
|
+
+ '<li class="failures"><a href="#">failures:</a> <em>0</em></li>'
|
|
1641
1704
|
+ '<li class="duration">duration: <em>0</em>s</li>'
|
|
1642
1705
|
+ '</ul>';
|
|
1643
1706
|
|
|
@@ -1658,7 +1721,9 @@ function HTML(runner) {
|
|
|
1658
1721
|
, stat = fragment(statsTemplate)
|
|
1659
1722
|
, items = stat.getElementsByTagName('li')
|
|
1660
1723
|
, passes = items[1].getElementsByTagName('em')[0]
|
|
1724
|
+
, passesLink = items[1].getElementsByTagName('a')[0]
|
|
1661
1725
|
, failures = items[2].getElementsByTagName('em')[0]
|
|
1726
|
+
, failuresLink = items[2].getElementsByTagName('a')[0]
|
|
1662
1727
|
, duration = items[3].getElementsByTagName('em')[0]
|
|
1663
1728
|
, canvas = stat.getElementsByTagName('canvas')[0]
|
|
1664
1729
|
, report = fragment('<ul id="report"></ul>')
|
|
@@ -1673,6 +1738,18 @@ function HTML(runner) {
|
|
|
1673
1738
|
|
|
1674
1739
|
if (!root) return error('#mocha div missing, add it to your document');
|
|
1675
1740
|
|
|
1741
|
+
// pass toggle
|
|
1742
|
+
on(passesLink, 'click', function () {
|
|
1743
|
+
var className = /pass/.test(report.className) ? '' : ' pass';
|
|
1744
|
+
report.className = report.className.replace(/fail|pass/g, '') + className;
|
|
1745
|
+
});
|
|
1746
|
+
|
|
1747
|
+
// failure toggle
|
|
1748
|
+
on(failuresLink, 'click', function () {
|
|
1749
|
+
var className = /fail/.test(report.className) ? '' : ' fail';
|
|
1750
|
+
report.className = report.className.replace(/fail|pass/g, '') + className;
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1676
1753
|
root.appendChild(stat);
|
|
1677
1754
|
root.appendChild(report);
|
|
1678
1755
|
|
|
@@ -1683,7 +1760,7 @@ function HTML(runner) {
|
|
|
1683
1760
|
|
|
1684
1761
|
// suite
|
|
1685
1762
|
var url = location.protocol + '//' + location.host + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle());
|
|
1686
|
-
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, suite.title);
|
|
1763
|
+
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
|
|
1687
1764
|
|
|
1688
1765
|
// container
|
|
1689
1766
|
stack[0].appendChild(el);
|
|
@@ -1701,6 +1778,8 @@ function HTML(runner) {
|
|
|
1701
1778
|
});
|
|
1702
1779
|
|
|
1703
1780
|
runner.on('test end', function(test){
|
|
1781
|
+
window.scrollTo(0, document.body.scrollHeight);
|
|
1782
|
+
|
|
1704
1783
|
// TODO: add to stats
|
|
1705
1784
|
var percent = stats.tests / total * 100 | 0;
|
|
1706
1785
|
if (progress) progress.update(percent).draw(ctx);
|
|
@@ -1738,17 +1817,16 @@ function HTML(runner) {
|
|
|
1738
1817
|
}
|
|
1739
1818
|
|
|
1740
1819
|
// toggle code
|
|
1741
|
-
var h2 = el.getElementsByTagName('h2')[0];
|
|
1742
|
-
|
|
1743
|
-
on(h2, 'click', function(){
|
|
1744
|
-
pre.style.display = 'none' == pre.style.display
|
|
1745
|
-
? 'block'
|
|
1746
|
-
: 'none';
|
|
1747
|
-
});
|
|
1748
|
-
|
|
1749
|
-
// code
|
|
1750
1820
|
// TODO: defer
|
|
1751
1821
|
if (!test.pending) {
|
|
1822
|
+
var h2 = el.getElementsByTagName('h2')[0];
|
|
1823
|
+
|
|
1824
|
+
on(h2, 'click', function(){
|
|
1825
|
+
pre.style.display = 'none' == pre.style.display
|
|
1826
|
+
? 'inline-block'
|
|
1827
|
+
: 'none';
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1752
1830
|
var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));
|
|
1753
1831
|
el.appendChild(pre);
|
|
1754
1832
|
pre.style.display = 'none';
|
|
@@ -1808,6 +1886,7 @@ function on(el, event, fn) {
|
|
|
1808
1886
|
el.attachEvent('on' + event, fn);
|
|
1809
1887
|
}
|
|
1810
1888
|
}
|
|
1889
|
+
|
|
1811
1890
|
}); // module: reporters/html.js
|
|
1812
1891
|
|
|
1813
1892
|
require.register("reporters/index.js", function(module, exports, require){
|
|
@@ -1821,13 +1900,14 @@ exports.HTML = require('./html');
|
|
|
1821
1900
|
exports.List = require('./list');
|
|
1822
1901
|
exports.Min = require('./min');
|
|
1823
1902
|
exports.Spec = require('./spec');
|
|
1903
|
+
exports.Nyan = require('./nyan');
|
|
1904
|
+
exports.XUnit = require('./xunit');
|
|
1824
1905
|
exports.Progress = require('./progress');
|
|
1825
1906
|
exports.Landing = require('./landing');
|
|
1826
1907
|
exports.JSONCov = require('./json-cov');
|
|
1827
1908
|
exports.HTMLCov = require('./html-cov');
|
|
1828
1909
|
exports.JSONStream = require('./json-stream');
|
|
1829
|
-
exports.
|
|
1830
|
-
exports.Teamcity = require('./teamcity')
|
|
1910
|
+
exports.Teamcity = require('./teamcity');
|
|
1831
1911
|
|
|
1832
1912
|
}); // module: reporters/index.js
|
|
1833
1913
|
|
|
@@ -2197,14 +2277,14 @@ function Landing(runner) {
|
|
|
2197
2277
|
}
|
|
2198
2278
|
|
|
2199
2279
|
// render landing strip
|
|
2200
|
-
stream.write('\
|
|
2280
|
+
stream.write('\u001b[4F\n\n');
|
|
2201
2281
|
stream.write(runway());
|
|
2202
2282
|
stream.write('\n ');
|
|
2203
2283
|
stream.write(color('runway', Array(col).join('⋅')));
|
|
2204
2284
|
stream.write(plane)
|
|
2205
2285
|
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
|
|
2206
2286
|
stream.write(runway());
|
|
2207
|
-
stream.write('\
|
|
2287
|
+
stream.write('\u001b[0m');
|
|
2208
2288
|
});
|
|
2209
2289
|
|
|
2210
2290
|
runner.on('end', function(){
|
|
@@ -2389,6 +2469,7 @@ function Markdown(runner) {
|
|
|
2389
2469
|
}); // module: reporters/markdown.js
|
|
2390
2470
|
|
|
2391
2471
|
require.register("reporters/min.js", function(module, exports, require){
|
|
2472
|
+
|
|
2392
2473
|
/**
|
|
2393
2474
|
* Module dependencies.
|
|
2394
2475
|
*/
|
|
@@ -2413,9 +2494,9 @@ function Min(runner) {
|
|
|
2413
2494
|
|
|
2414
2495
|
runner.on('start', function(){
|
|
2415
2496
|
// clear screen
|
|
2416
|
-
process.stdout.write('\
|
|
2497
|
+
process.stdout.write('\u001b[2J');
|
|
2417
2498
|
// set cursor position
|
|
2418
|
-
process.stdout.write('\
|
|
2499
|
+
process.stdout.write('\u001b[1;3H');
|
|
2419
2500
|
});
|
|
2420
2501
|
|
|
2421
2502
|
runner.on('end', this.epilogue.bind(this));
|
|
@@ -2520,7 +2601,7 @@ NyanCat.prototype.drawScoreboard = function(){
|
|
|
2520
2601
|
|
|
2521
2602
|
function draw(color, n) {
|
|
2522
2603
|
write(' ');
|
|
2523
|
-
write('\
|
|
2604
|
+
write('\u001b[' + color + 'm' + n + '\u001b[0m');
|
|
2524
2605
|
write('\n');
|
|
2525
2606
|
}
|
|
2526
2607
|
|
|
@@ -2559,7 +2640,7 @@ NyanCat.prototype.drawRainbow = function(){
|
|
|
2559
2640
|
var self = this;
|
|
2560
2641
|
|
|
2561
2642
|
this.trajectories.forEach(function(line, index) {
|
|
2562
|
-
write('\
|
|
2643
|
+
write('\u001b[' + self.scoreboardWidth + 'C');
|
|
2563
2644
|
write(line.join(''));
|
|
2564
2645
|
write('\n');
|
|
2565
2646
|
});
|
|
@@ -2579,7 +2660,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
|
|
|
2579
2660
|
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
2580
2661
|
|
|
2581
2662
|
[0, 1, 2, 3].forEach(function(index) {
|
|
2582
|
-
write('\
|
|
2663
|
+
write('\u001b[' + startWidth + 'C');
|
|
2583
2664
|
|
|
2584
2665
|
switch (index) {
|
|
2585
2666
|
case 0:
|
|
@@ -2627,7 +2708,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
|
|
|
2627
2708
|
*/
|
|
2628
2709
|
|
|
2629
2710
|
NyanCat.prototype.cursorUp = function(n) {
|
|
2630
|
-
write('\
|
|
2711
|
+
write('\u001b[' + n + 'A');
|
|
2631
2712
|
};
|
|
2632
2713
|
|
|
2633
2714
|
/**
|
|
@@ -2638,7 +2719,7 @@ NyanCat.prototype.cursorUp = function(n) {
|
|
|
2638
2719
|
*/
|
|
2639
2720
|
|
|
2640
2721
|
NyanCat.prototype.cursorDown = function(n) {
|
|
2641
|
-
write('\
|
|
2722
|
+
write('\u001b[' + n + 'B');
|
|
2642
2723
|
};
|
|
2643
2724
|
|
|
2644
2725
|
/**
|
|
@@ -2674,7 +2755,7 @@ NyanCat.prototype.generateColors = function(){
|
|
|
2674
2755
|
NyanCat.prototype.rainbowify = function(str){
|
|
2675
2756
|
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
|
|
2676
2757
|
this.colorIndex += 1;
|
|
2677
|
-
return '\
|
|
2758
|
+
return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
|
|
2678
2759
|
};
|
|
2679
2760
|
|
|
2680
2761
|
/**
|
|
@@ -2758,7 +2839,7 @@ function Progress(runner, options) {
|
|
|
2758
2839
|
, i = width - n;
|
|
2759
2840
|
|
|
2760
2841
|
cursor.CR();
|
|
2761
|
-
process.stdout.write('\
|
|
2842
|
+
process.stdout.write('\u001b[J');
|
|
2762
2843
|
process.stdout.write(color('progress', ' ' + options.open));
|
|
2763
2844
|
process.stdout.write(Array(n).join(options.complete));
|
|
2764
2845
|
process.stdout.write(Array(i).join(options.incomplete));
|
|
@@ -3055,7 +3136,11 @@ function XUnit(runner) {
|
|
|
3055
3136
|
, tests = []
|
|
3056
3137
|
, self = this;
|
|
3057
3138
|
|
|
3058
|
-
runner.on('
|
|
3139
|
+
runner.on('pass', function(test){
|
|
3140
|
+
tests.push(test);
|
|
3141
|
+
});
|
|
3142
|
+
|
|
3143
|
+
runner.on('fail', function(test){
|
|
3059
3144
|
tests.push(test);
|
|
3060
3145
|
});
|
|
3061
3146
|
|
|
@@ -3140,7 +3225,7 @@ require.register("runnable.js", function(module, exports, require){
|
|
|
3140
3225
|
*/
|
|
3141
3226
|
|
|
3142
3227
|
var EventEmitter = require('browser/events').EventEmitter
|
|
3143
|
-
, debug = require('browser/debug')('runnable');
|
|
3228
|
+
, debug = require('browser/debug')('mocha:runnable');
|
|
3144
3229
|
|
|
3145
3230
|
/**
|
|
3146
3231
|
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
@@ -3284,16 +3369,16 @@ Runnable.prototype.run = function(fn){
|
|
|
3284
3369
|
}
|
|
3285
3370
|
|
|
3286
3371
|
// called multiple times
|
|
3287
|
-
function multiple() {
|
|
3372
|
+
function multiple(err) {
|
|
3288
3373
|
if (emitted) return;
|
|
3289
3374
|
emitted = true;
|
|
3290
|
-
self.emit('error', new Error('done() called multiple times'));
|
|
3375
|
+
self.emit('error', err || new Error('done() called multiple times'));
|
|
3291
3376
|
}
|
|
3292
3377
|
|
|
3293
3378
|
// finished
|
|
3294
3379
|
function done(err) {
|
|
3295
3380
|
if (self.timedOut) return;
|
|
3296
|
-
if (finished) return multiple();
|
|
3381
|
+
if (finished) return multiple(err);
|
|
3297
3382
|
self.clearTimeout();
|
|
3298
3383
|
self.duration = new Date - start;
|
|
3299
3384
|
finished = true;
|
|
@@ -3336,7 +3421,7 @@ require.register("runner.js", function(module, exports, require){
|
|
|
3336
3421
|
*/
|
|
3337
3422
|
|
|
3338
3423
|
var EventEmitter = require('browser/events').EventEmitter
|
|
3339
|
-
, debug = require('browser/debug')('runner')
|
|
3424
|
+
, debug = require('browser/debug')('mocha:runner')
|
|
3340
3425
|
, Test = require('./test')
|
|
3341
3426
|
, utils = require('./utils')
|
|
3342
3427
|
, filter = utils.filter
|
|
@@ -3393,13 +3478,15 @@ Runner.prototype.constructor = Runner;
|
|
|
3393
3478
|
* with number of tests matched.
|
|
3394
3479
|
*
|
|
3395
3480
|
* @param {RegExp} re
|
|
3481
|
+
* @param {Boolean} invert
|
|
3396
3482
|
* @return {Runner} for chaining
|
|
3397
3483
|
* @api public
|
|
3398
3484
|
*/
|
|
3399
3485
|
|
|
3400
|
-
Runner.prototype.grep = function(re){
|
|
3486
|
+
Runner.prototype.grep = function(re, invert){
|
|
3401
3487
|
debug('grep %s', re);
|
|
3402
3488
|
this._grep = re;
|
|
3489
|
+
this._invert = invert;
|
|
3403
3490
|
this.total = this.grepTotal(this.suite);
|
|
3404
3491
|
return this;
|
|
3405
3492
|
};
|
|
@@ -3418,7 +3505,9 @@ Runner.prototype.grepTotal = function(suite) {
|
|
|
3418
3505
|
var total = 0;
|
|
3419
3506
|
|
|
3420
3507
|
suite.eachTest(function(test){
|
|
3421
|
-
|
|
3508
|
+
var match = self._grep.test(test.fullTitle());
|
|
3509
|
+
if (self._invert) match = !match;
|
|
3510
|
+
if (match) total++;
|
|
3422
3511
|
});
|
|
3423
3512
|
|
|
3424
3513
|
return total;
|
|
@@ -3658,7 +3747,9 @@ Runner.prototype.runTests = function(suite, fn){
|
|
|
3658
3747
|
if (!test) return fn();
|
|
3659
3748
|
|
|
3660
3749
|
// grep
|
|
3661
|
-
|
|
3750
|
+
var match = self._grep.test(test.fullTitle());
|
|
3751
|
+
if (self._invert) match = !match;
|
|
3752
|
+
if (!match) return next();
|
|
3662
3753
|
|
|
3663
3754
|
// pending
|
|
3664
3755
|
if (test.pending) {
|
|
@@ -3739,9 +3830,9 @@ Runner.prototype.runSuite = function(suite, fn){
|
|
|
3739
3830
|
*/
|
|
3740
3831
|
|
|
3741
3832
|
Runner.prototype.uncaught = function(err){
|
|
3742
|
-
debug('uncaught exception');
|
|
3833
|
+
debug('uncaught exception %s', err.message);
|
|
3743
3834
|
var runnable = this.currentRunnable;
|
|
3744
|
-
if ('failed' == runnable.state) return;
|
|
3835
|
+
if (!runnable || 'failed' == runnable.state) return;
|
|
3745
3836
|
runnable.clearTimeout();
|
|
3746
3837
|
err.uncaught = true;
|
|
3747
3838
|
this.fail(runnable, err);
|
|
@@ -3823,7 +3914,7 @@ require.register("suite.js", function(module, exports, require){
|
|
|
3823
3914
|
*/
|
|
3824
3915
|
|
|
3825
3916
|
var EventEmitter = require('browser/events').EventEmitter
|
|
3826
|
-
, debug = require('browser/debug')('suite')
|
|
3917
|
+
, debug = require('browser/debug')('mocha:suite')
|
|
3827
3918
|
, utils = require('./utils')
|
|
3828
3919
|
, Hook = require('./hook');
|
|
3829
3920
|
|
|
@@ -3849,6 +3940,7 @@ exports = module.exports = Suite;
|
|
|
3849
3940
|
exports.create = function(parent, title){
|
|
3850
3941
|
var suite = new Suite(title, parent.ctx);
|
|
3851
3942
|
suite.parent = parent;
|
|
3943
|
+
if (parent.pending) suite.pending = true;
|
|
3852
3944
|
title = suite.fullTitle();
|
|
3853
3945
|
parent.addSuite(suite);
|
|
3854
3946
|
return suite;
|
|
@@ -3868,6 +3960,7 @@ function Suite(title, ctx) {
|
|
|
3868
3960
|
this.ctx = ctx;
|
|
3869
3961
|
this.suites = [];
|
|
3870
3962
|
this.tests = [];
|
|
3963
|
+
this.pending = false;
|
|
3871
3964
|
this._beforeEach = [];
|
|
3872
3965
|
this._beforeAll = [];
|
|
3873
3966
|
this._afterEach = [];
|
|
@@ -3941,6 +4034,7 @@ Suite.prototype.bail = function(bail){
|
|
|
3941
4034
|
*/
|
|
3942
4035
|
|
|
3943
4036
|
Suite.prototype.beforeAll = function(fn){
|
|
4037
|
+
if (this.pending) return this;
|
|
3944
4038
|
var hook = new Hook('"before all" hook', fn);
|
|
3945
4039
|
hook.parent = this;
|
|
3946
4040
|
hook.timeout(this.timeout());
|
|
@@ -3959,6 +4053,7 @@ Suite.prototype.beforeAll = function(fn){
|
|
|
3959
4053
|
*/
|
|
3960
4054
|
|
|
3961
4055
|
Suite.prototype.afterAll = function(fn){
|
|
4056
|
+
if (this.pending) return this;
|
|
3962
4057
|
var hook = new Hook('"after all" hook', fn);
|
|
3963
4058
|
hook.parent = this;
|
|
3964
4059
|
hook.timeout(this.timeout());
|
|
@@ -3977,6 +4072,7 @@ Suite.prototype.afterAll = function(fn){
|
|
|
3977
4072
|
*/
|
|
3978
4073
|
|
|
3979
4074
|
Suite.prototype.beforeEach = function(fn){
|
|
4075
|
+
if (this.pending) return this;
|
|
3980
4076
|
var hook = new Hook('"before each" hook', fn);
|
|
3981
4077
|
hook.parent = this;
|
|
3982
4078
|
hook.timeout(this.timeout());
|
|
@@ -3995,6 +4091,7 @@ Suite.prototype.beforeEach = function(fn){
|
|
|
3995
4091
|
*/
|
|
3996
4092
|
|
|
3997
4093
|
Suite.prototype.afterEach = function(fn){
|
|
4094
|
+
if (this.pending) return this;
|
|
3998
4095
|
var hook = new Hook('"after each" hook', fn);
|
|
3999
4096
|
hook.parent = this;
|
|
4000
4097
|
hook.timeout(this.timeout());
|
|
@@ -4134,7 +4231,7 @@ require.register("utils.js", function(module, exports, require){
|
|
|
4134
4231
|
var fs = require('browser/fs')
|
|
4135
4232
|
, path = require('browser/path')
|
|
4136
4233
|
, join = path.join
|
|
4137
|
-
, debug = require('browser/debug')('watch');
|
|
4234
|
+
, debug = require('browser/debug')('mocha:watch');
|
|
4138
4235
|
|
|
4139
4236
|
/**
|
|
4140
4237
|
* Ignored directories.
|
package/my-reporter.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
exports = module.exports = MyReporter;
|
|
3
|
+
|
|
4
|
+
function MyReporter(runner) {
|
|
5
|
+
var passes = 0;
|
|
6
|
+
var failures = 0;
|
|
7
|
+
var total = 0;
|
|
8
|
+
|
|
9
|
+
runner.on('pass', function(test){
|
|
10
|
+
passes++;
|
|
11
|
+
console.log('pass: %s', test.fullTitle());
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
runner.on('fail', function(test, err){
|
|
15
|
+
failures++;
|
|
16
|
+
console.log('fail: %s -- error: %s', test.fullTitle(), err.message);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
runner.on('end', function(){
|
|
20
|
+
console.log('end: %d/%d', passes, passes + failures);
|
|
21
|
+
process.exit(failures);
|
|
22
|
+
});
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha"
|
|
3
|
-
, "version": "1.2
|
|
3
|
+
, "version": "1.3.2"
|
|
4
4
|
, "description": "simple, flexible, fun test framework"
|
|
5
5
|
, "keywords": ["test", "bdd", "tdd", "tap"]
|
|
6
6
|
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
, "bin": { "mocha": "./bin/mocha", "_mocha": "./bin/_mocha" }
|
|
10
10
|
, "engines": { "node": ">= 0.4.x" }
|
|
11
11
|
, "scripts": {
|
|
12
|
-
"test": "make test"
|
|
12
|
+
"test": "make test-all"
|
|
13
13
|
}
|
|
14
14
|
, "dependencies":{
|
|
15
15
|
"commander": "0.6.1"
|
package/test.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
describe('
|
|
3
|
-
it('should
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
it('should two', function(){
|
|
8
|
-
this.ok = false;
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
afterEach(function(){
|
|
12
|
-
if (!this.ok) this.test.error(new Error('something went wrong'));
|
|
2
|
+
describe('foo', function(){
|
|
3
|
+
it('should bar', function(){
|
|
4
|
+
var obj = { name: 'tobi', age: 2, species: 'ferret', friends: [] };
|
|
5
|
+
var other = { name: 'tobi', age: 3, species: 'ferret', friends: ['loki', 'jane'] };
|
|
6
|
+
obj.should.eql(other);
|
|
13
7
|
})
|
|
14
8
|
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>content</key>
|
|
6
|
-
<string>afterEach(function(){
|
|
7
|
-
$0
|
|
8
|
-
})</string>
|
|
9
|
-
<key>name</key>
|
|
10
|
-
<string>bdd - after each</string>
|
|
11
|
-
<key>tabTrigger</key>
|
|
12
|
-
<string>ae</string>
|
|
13
|
-
<key>uuid</key>
|
|
14
|
-
<string>7B4DA8F4-2064-468B-B252-054148419B4B</string>
|
|
15
|
-
</dict>
|
|
16
|
-
</plist>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>content</key>
|
|
6
|
-
<string>after(function(){
|
|
7
|
-
$0
|
|
8
|
-
})</string>
|
|
9
|
-
<key>name</key>
|
|
10
|
-
<string>bdd - after</string>
|
|
11
|
-
<key>tabTrigger</key>
|
|
12
|
-
<string>a</string>
|
|
13
|
-
<key>uuid</key>
|
|
14
|
-
<string>A49A87F9-399E-4D74-A489-C535BB06D487</string>
|
|
15
|
-
</dict>
|
|
16
|
-
</plist>
|