Comparing version 2.0.0 to 2.1.0
64
index.js
@@ -79,5 +79,11 @@ var through = require('through2'); | ||
: format.red(symbols.err); | ||
if (!res.ok) { | ||
errors.push({ | ||
assertName: res.name, | ||
testName: currentTestName, | ||
testNumber: testNumber | ||
}); | ||
} | ||
if (!res.ok) errors.push(currentTestName + ' ' + res.name); | ||
out.push(' ' + output + ' ' + format.gray(res.name) + '\n'); | ||
@@ -97,2 +103,35 @@ }); | ||
if (errors.length) { | ||
var past = (errors.length == 1) ? 'was' : 'were'; | ||
var plural = (errors.length == 1) ? 'failure' : 'failures'; | ||
out.push(' ' + format.red.bold('Failed Tests: ')); | ||
out.push('There ' + past + ' ' + format.red.bold(errors.length) + ' ' + plural + '\n\n'); | ||
// Group the errors by test name | ||
var groupedErrors = {}; | ||
errors.forEach(function (error) { | ||
var name = error.testNumber + ') ' + error.testName; | ||
groupedErrors[name] = groupedErrors[name] || []; | ||
groupedErrors[name].push(error); | ||
}); | ||
Object.keys(groupedErrors).forEach(function (name) { | ||
var errors = groupedErrors[name]; | ||
out.push(' ' + name + '\n\n'); | ||
errors.forEach(function (error) { | ||
out.push(' ' + format.red(symbols.err) + ' ' + format.red(error.assertName) + '\n'); | ||
}); | ||
out.push('\n'); | ||
}); | ||
out.push('\n'); | ||
} | ||
// Test number | ||
@@ -111,25 +150,6 @@ out.push(' total: ' + res.asserts.length + '\n'); | ||
if (errors.length) { | ||
var past = (errors.length == 1) ? 'was' : 'were'; | ||
var plural = (errors.length == 1) ? 'failure' : 'failures'; | ||
out.push(' ' + format.red('Failed Tests: ')); | ||
out.push('There ' + past + ' ' + format.red(errors.length) + ' ' + plural + '\n\n'); | ||
errors.forEach(function (error) { | ||
out.push(' ' + format.red(symbols.err) + ' ' + format.red(error) + '\n'); | ||
}); | ||
} | ||
else if (!res.ok) { | ||
out.push(' ' + format.red('Fail!') + '\n'); | ||
} | ||
else{ | ||
if (res.ok) { | ||
out.push(' ' + format.green.bold('All tests pass!') + '\n'); | ||
} | ||
out.push('\n'); | ||
// Expose errors and res on returned dup stream | ||
@@ -136,0 +156,0 @@ dup.errors = errors; |
{ | ||
"name": "tap-spec", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Formatted TAP output like Mocha's spec reporter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # tap-spec | ||
![screen shot 2014-11-20 at 3 32 32 pm](https://cloud.githubusercontent.com/assets/974723/5135186/a7d15ff6-70ca-11e4-9526-e1e5cbaa0f4b.png) | ||
![screen shot 2014-11-20 at 4 11 03 pm](https://cloud.githubusercontent.com/assets/974723/5135660/d83bb344-70cf-11e4-98c1-cca14d76d5a7.png) | ||
@@ -8,0 +8,0 @@ ## Install |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5481
130