Skip to content

armgit / mocha

Public Imported from GitHub
0

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

add Mocha#invert() to js api

TJ Holowaychuk2092bdef524d
diff --git a/lib/mocha.js b/lib/mocha.js
index b9ad3f9d..9cfc704a 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -165,6 +165,18 @@ Mocha.prototype.grep = function(re){
return this;
};
+/**
+ * Invert `.grep()` matches.
+ *
+ * @return {Mocha}
+ * @api public
+ */
+
+Mocha.prototype.invert = function(){
+ this.options.invert = true;
+ return this;
+};
+
/**
* Run tests and invoke `fn()` when complete.
*
@@ -180,7 +192,7 @@ Mocha.prototype.run = function(fn){
var runner = new exports.Runner(suite);
var reporter = new this._reporter(runner);
runner.ignoreLeaks = options.ignoreLeaks;
- if (options.grep) runner.grep(options.grep);
+ if (options.grep) runner.grep(options.grep, options.invert);
if (options.globals) runner.globals(options.globals);
if (options.growl) this.growl(runner, reporter);
return runner.run(fn);