☕️ Classic, reliable, trusted test framework for Node.js and the browser
Allow --async-only to be satisfied by returning a promise
Jason Lai242ee53a5d23
diff --git a/bin/_mocha b/bin/_mochaindex 1129178b..4ddbc08f 100755--- a/bin/_mocha+++ b/bin/_mocha@@ -58,7 +58,7 @@ var images = {program.version(JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version).usage('[debug] [options] [files]')- .option('-A, --async-only', "force all tests to take a callback (async)")+ .option('-A, --async-only', "force all tests to take a callback (async) or return a promise").option('-c, --colors', 'force enabling of colors').option('-C, --no-colors', 'force disabling of colors').option('-G, --growl', 'enable growl notification support')diff --git a/lib/runnable.js b/lib/runnable.jsindex d0c0f607..a048d4a0 100644--- a/lib/runnable.js+++ b/lib/runnable.js@@ -274,10 +274,6 @@ Runnable.prototype.run = function(fn) {return;}- if (this.asyncOnly) {- return done(new Error('--async-only option in use without declaring `done()`'));- }-// sync or promise-returningtry {if (this.pending) {@@ -301,6 +297,10 @@ Runnable.prototype.run = function(fn) {done(reason || new Error('Promise rejected with no or falsy reason'));});} else {+ if (self.asyncOnly) {+ return done(new Error('--async-only option in use without declaring `done()` or returning a promise'));+ }+done();}}