From 653d7937307b3677da0d6947af5c74fd5e959259 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Tue, 5 Jul 2016 15:41:12 +0200 Subject: [PATCH] fix(runner): better reporting --- src/reporter.js | 2 +- src/runner.js | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/reporter.js b/src/reporter.js index 6531d11..db38360 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -238,7 +238,7 @@ module.exports = function (runner) { ); } - if (t.above.length) { + if (t.above && t.above.length) { write(log.info('- Above median : ') + '\n'); for (i = 0, max = t.above.length; i < max; i += 1) { write(log.info(' - ' + t.above[i].test.it + ' ') + '\n'); diff --git a/src/runner.js b/src/runner.js index 813ea57..5207d5e 100644 --- a/src/runner.js +++ b/src/runner.js @@ -74,24 +74,28 @@ Runner.prototype.unbindings = function unbindings () { Runner.prototype.createReport = function createReport () { this.report = { tasks: this.tasks, - timing: {} + timing: {}, + errors: { + byTask: {}, + byError: {} + } }; - if (!_.isEmpty(this.tasks)) { + if (_.isEmpty(this.tasks)) { return this.report; } // Total time of everything this.report.timing.total = _.reduce(this.tasks, function (memo, task) { - return memo + task.test.duration; + return memo + (task.test.duration || 0); }, 0); // The longest task this.report.timing.slowest = _.max(this.tasks, function (task) { - return task.test.duration; + return (task.test.duration || 0); }); // The fastest task this.report.timing.fastest = _.min(this.tasks, function (task) { - return task.test.duration; + return (task.test.duration || 0); }); // All the tasks that are above the median this.report.timing.above = _.filter(this.tasks, function (task) { @@ -99,12 +103,6 @@ Runner.prototype.createReport = function createReport () { (this.report.timing.slowest.test.duration / 2); }.bind(this)); - // All the errors - this.report.errors = { - byTask: {}, - byError: {} - }; - // Different indexation _.each(this.tasks, function (task) { if (task.errors.length) {