@johanblumenberg/mocha
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -368,2 +368,16 @@ 'use strict'; | ||
/** | ||
* Add a list of tests to be excluded | ||
* | ||
* @public | ||
* @param {Object} from | ||
* @return {Mocha} | ||
* @api public | ||
* @param {Object} from | ||
* @return {Mocha} | ||
*/ | ||
Mocha.prototype.excludeFrom = function(from) { | ||
this.options.excludeFrom = from; | ||
return this; | ||
}; | ||
/** | ||
* Add regexp to grepv, if `re` is a string it is escaped. | ||
@@ -676,3 +690,3 @@ * | ||
runner.forbidPending = options.forbidPending; | ||
runner.grep(options.grep, options.grepv, options.invert); | ||
runner.grep(options.grep, options.grepv, options.excludeFrom, options.invert); | ||
if (options.globals) { | ||
@@ -679,0 +693,0 @@ runner.globals(options.globals); |
@@ -108,6 +108,7 @@ 'use strict'; | ||
*/ | ||
Runner.prototype.grep = function(re, rev, invert) { | ||
Runner.prototype.grep = function(re, rev, from, invert) { | ||
debug('grep %s', re); | ||
this._grep = re; | ||
this._grepv = rev; | ||
this._excludeFrom = from; | ||
this._invert = invert; | ||
@@ -126,2 +127,9 @@ this.total = this.grepTotal(this.suite); | ||
} | ||
if (this._excludeFrom) { | ||
match = | ||
match && | ||
!this._excludeFrom.some(function(e) { | ||
return title === e.fullTitle; | ||
}); | ||
} | ||
if (this._invert) { | ||
@@ -128,0 +136,0 @@ match = !match; |
{ | ||
"name": "@johanblumenberg/mocha", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "simple, flexible, fun test framework", | ||
@@ -469,2 +469,3 @@ "keywords": [ | ||
"escape-string-regexp": "1.0.5", | ||
"fs-extra": "^8.1.0", | ||
"glob": "7.1.2", | ||
@@ -471,0 +472,0 @@ "growl": "1.10.5", |
@@ -16,2 +16,3 @@ # @johanblumenberg/mocha | ||
- Support for '--grepv' to exclude tests from running. | ||
- Support excluding tests from file using `--exclude-from` | ||
@@ -109,1 +110,15 @@ ## Purpose | ||
``` | ||
### `--exclude-from <file>` | ||
This is used to exclude tests from a file. | ||
The format of the file is the same as generated by the `json` reporter. | ||
This can be useful to be able to run only the tests that are new. If test results are recorded when running on master, this information can be used to identify which tests that are added. | ||
The example below will use the test results from a master build to identify which tests are new, and run those tests 10 times. | ||
```bash | ||
$ mocha **/*.spec.js --exclude-from master-test-results.json --repeat 10 | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
794742
20730
123
14
+ Addedfs-extra@^8.1.0
+ Addedfs-extra@8.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addeduniversalify@0.1.2(transitive)