Skip to content

Commit

Permalink
Merge pull request #464 from sotojuan/fix-undefined-skip
Browse files Browse the repository at this point in the history
Fix undefined skip count
  • Loading branch information
sindresorhus committed Jan 23, 2016
2 parents 3f98ac1 + 24b234d commit da0cce6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/reporters/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ TapReporter.prototype.finish = function () {
'',
'1..' + (this.api.passCount + this.api.failCount),
'# tests ' + (this.api.passCount + this.api.failCount),
'# pass ' + this.api.passCount,
'# skip ' + this.api.skipCount,
'# fail ' + (this.api.failCount + this.api.rejectionCount + this.api.exceptionCount),
''
'# pass ' + this.api.passCount
];

if (this.api.skipCount > 0) {
output.push('# skip ' + this.api.skipCount);
}

output.push('# fail ' + (this.api.failCount + this.api.rejectionCount + this.api.exceptionCount), '');

return output.join('\n');
};

Expand Down
26 changes: 26 additions & 0 deletions test/reporters/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,29 @@ test('results', function (t) {
t.is(actualOutput, expectedOutput);
t.end();
});

test('results does not show skipped tests if there are none', function (t) {
var reporter = tapReporter();
var api = {
passCount: 1,
failCount: 2,
skipCount: 0,
rejectionCount: 3,
exceptionCount: 4
};

reporter.api = api;

var actualOutput = reporter.finish();
var expectedOutput = [
'',
'1..' + (api.passCount + api.failCount),
'# tests ' + (api.passCount + api.failCount),
'# pass ' + api.passCount,
'# fail ' + (api.failCount + api.rejectionCount + api.exceptionCount),
''
].join('\n');

t.is(actualOutput, expectedOutput);
t.end();
});

0 comments on commit da0cce6

Please sign in to comment.