☕️ Classic, reliable, trusted test framework for Node.js and the browser
Added: return Runner from `mocha.run()`. Closes #126
Tj Holowaychuk9b03e7f9cfb4
diff --git a/lib/runner.js b/lib/runner.jsindex 162e48d3..378a0e78 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -365,6 +365,7 @@ Runner.prototype.runSuite = function(suite, fn){* on completion.** @param {Function} fn+ * @return {Runner} for chaining* @api public*/diff --git a/mocha.js b/mocha.jsindex abf7ff62..9aeeaae1 100644--- a/mocha.js+++ b/mocha.js@@ -1985,6 +1985,7 @@ Runner.prototype.runSuite = function(suite, fn){* on completion.** @param {Function} fn+ * @return {Runner} for chaining* @api public*/@@ -2392,6 +2393,6 @@ mocha = require('mocha');var reporter = new Reporter(runner);var query = parse(window.location.search || "");if (query.grep) runner.grep(new RegExp(query.grep));- runner.run();+ return runner.run();};})();diff --git a/support/tail.js b/support/tail.jsindex df46a53b..b00d7b10 100644--- a/support/tail.js+++ b/support/tail.js@@ -50,6 +50,6 @@ mocha = require('mocha');var reporter = new Reporter(runner);var query = parse(window.location.search || "");if (query.grep) runner.grep(new RegExp(query.grep));- runner.run();+ return runner.run();};})();diff --git a/test/browser/index.html b/test/browser/index.htmlindex 857996fe..69f525cd 100644--- a/test/browser/index.html+++ b/test/browser/index.html@@ -14,7 +14,16 @@<script src="array.js"></script><script src="../duration.js"></script><script src="../timeout.js"></script>- <script>onload = mocha.run;</script>+ <script>+ onload = function(){+ var runner = mocha.run();+ runner.globals(['foo', 'bar', 'baz']);++ runner.on('test end', function(test){+ console.log(test.fullTitle());+ });+ };+ </script></head><body><div id="mocha"></div>