Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Update mocha.js

Travis Jefferyd663f03ffecb
diff --git a/mocha.js b/mocha.js
index 16fbb8a3..0049a3b4 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1640,6 +1640,21 @@ Mocha.prototype.useColors = function(colors){
return this;
};
+/**
+ * Use inline diffs rather than +/-.
+ *
+ * @param {Boolean} inlineDiffs
+ * @return {Mocha}
+ * @api public
+ */
+
+Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
+ this.options.useInlineDiffs = arguments.length && inlineDiffs != undefined
+ ? inlineDiffs
+ : false;
+ return this;
+};
+
/**
* Set the timeout in milliseconds.
*
@@ -1698,6 +1713,7 @@ Mocha.prototype.run = function(fn){
if (options.globals) runner.globals(options.globals);
if (options.growl) this._growl(runner, reporter);
exports.reporters.Base.useColors = options.useColors;
+ exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
return runner.run(fn);
};
@@ -1730,9 +1746,7 @@ var y = d * 365.25;
module.exports = function(val, options){
options = options || {};
if ('string' == typeof val) return parse(val);
- return options.long
- ? long(val)
- : short(val);
+ return options.long ? longFormat(val) : shortFormat(val);
};
/**
@@ -1782,7 +1796,7 @@ function parse(str) {
* @api private
*/
-function short(ms) {
+function shortFormat(ms) {
if (ms >= d) return Math.round(ms / d) + 'd';
if (ms >= h) return Math.round(ms / h) + 'h';
if (ms >= m) return Math.round(ms / m) + 'm';
@@ -1798,7 +1812,7 @@ function short(ms) {
* @api private
*/
-function long(ms) {
+function longFormat(ms) {
return plural(ms, d, 'day')
|| plural(ms, h, 'hour')
|| plural(ms, m, 'minute')
@@ -3961,6 +3975,10 @@ function XUnit(runner) {
, tests = []
, self = this;
+ runner.on('pending', function(test){
+ tests.push(test);
+ });
+
runner.on('pass', function(test){
tests.push(test);
});