Skip to content

armgit / mocha

Public Imported from GitHub
0

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

exposed stats via runner to allow access via "end" callback

Wil Moore III3f67c9ee3a3a
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index a0fc131e..7d1b9fde 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -210,6 +210,7 @@ function Base(runner) {
if (!runner) return;
this.runner = runner;
+ runner.stats= stats;
runner.on('start', function(){
stats.start = new Date;
diff --git a/mocha.js b/mocha.js
index b27c2df7..a38e5fae 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1531,6 +1531,7 @@ function Base(runner) {
if (!runner) return;
this.runner = runner;
+ runner.stats= stats;
runner.on('start', function(){
stats.start = new Date;
@@ -3461,7 +3462,8 @@ require.register("runnable.js", function(module, exports, require){
*/
var EventEmitter = require('browser/events').EventEmitter
- , debug = require('browser/debug')('mocha:runnable');
+ , debug = require('browser/debug')('mocha:runnable')
+ , milliseconds = require('./ms');
/**
* Save timer references to avoid Sinon interfering (see GH-237).
@@ -3508,13 +3510,14 @@ Runnable.prototype.constructor = Runnable;
/**
* Set & get timeout `ms`.
*
- * @param {Number} ms
+ * @param {Number|String} ms
* @return {Runnable|Number} ms or self
* @api private
*/
Runnable.prototype.timeout = function(ms){
if (0 == arguments.length) return this._timeout;
+ if ('string' == typeof ms) ms = milliseconds(ms);
debug('timeout %d', ms);
this._timeout = ms;
if (this.timer) this.resetTimeout();
@@ -3524,13 +3527,14 @@ Runnable.prototype.timeout = function(ms){
/**
* Set & get slow `ms`.
*
- * @param {Number} ms
+ * @param {Number|String} ms
* @return {Runnable|Number} ms or self
* @api private
*/
Runnable.prototype.slow = function(ms){
if (0 === arguments.length) return this._slow;
+ if ('string' == typeof ms) ms = milliseconds(ms);
debug('timeout %d', ms);
this._slow = ms;
return this;
@@ -3992,7 +3996,7 @@ Runner.prototype.runTest = function(fn){
Runner.prototype.runTests = function(suite, fn){
var self = this
- , tests = suite.tests
+ , tests = suite.tests.slice()
, test;
function next(err) {