Skip to content

Commit 521b7e4

Browse files
committed
Update mocha.js
1 parent 994e65e commit 521b7e4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

mocha.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,8 @@ function Mocha(options) {
14801480
options = options || {};
14811481
this.files = [];
14821482
this.options = options;
1483-
this.grep(options.grep);
1483+
if (options.grep) this.grep(new RegExp(options.grep));
1484+
if (options.fgrep) this.grep(options.fgrep);
14841485
this.suite = new exports.Suite('', new exports.Context);
14851486
this.ui(options.ui);
14861487
this.bail(options.bail);
@@ -4481,6 +4482,10 @@ Runnable.prototype.run = function(fn){
44814482
var ms = self.timeout();
44824483
if (self.timedOut) return;
44834484
if (finished) return multiple(err || self._trace);
4485+
4486+
// Discard the resolution if this test has already failed asynchronously
4487+
if (self.state) return;
4488+
44844489
self.clearTimeout();
44854490
self.duration = new Date - start;
44864491
finished = true;
@@ -5127,12 +5132,11 @@ Runner.prototype.uncaught = function(err){
51275132
var runnable = this.currentRunnable;
51285133
if (!runnable) return;
51295134

5130-
var wasAlreadyDone = runnable.state;
5131-
this.fail(runnable, err);
5132-
51335135
runnable.clearTimeout();
51345136

5135-
if (wasAlreadyDone) return;
5137+
// Ignore errors if complete
5138+
if (runnable.state) return;
5139+
this.fail(runnable, err);
51365140

51375141
// recover from test
51385142
if ('test' == runnable.type) {
@@ -6447,6 +6451,7 @@ mocha.run = function(fn){
64476451

64486452
var query = Mocha.utils.parseQuery(global.location.search || '');
64496453
if (query.grep) mocha.grep(new RegExp(query.grep));
6454+
if (query.fgrep) mocha.grep(query.fgrep);
64506455
if (query.invert) mocha.invert();
64516456

64526457
return Mocha.prototype.run.call(mocha, function(err){

0 commit comments

Comments
 (0)