Skip to content

Commit

Permalink
fix(runner): better reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannmoinet committed Jul 5, 2016
1 parent aa34367 commit 653d793
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
20 changes: 9 additions & 11 deletions src/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,35 @@ 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) {
return task.test.duration >
(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) {
Expand Down

0 comments on commit 653d793

Please sign in to comment.