Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fix inline diffs (close #1044)

Travis Jefferya918737bc05c
diff --git a/bin/_mocha b/bin/_mocha
index 79bd89ea..055e3ea1 100644
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -212,7 +212,7 @@ if (~process.argv.indexOf('--colors') ||
// --inline-diffs
-if (program.inlineDiffs) Base.inlineDiffs = true;
+if (program.inlineDiffs) mocha.useInlineDiffs(true);
// --slow <ms>
diff --git a/lib/mocha.js b/lib/mocha.js
index 5d3f3ba3..53543546 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -276,6 +276,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.
*
@@ -334,5 +349,6 @@ 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);
};