Skip to content

Commit

Permalink
Print the planned and actual assertion count when incorrect.
Browse files Browse the repository at this point in the history
Fixes avajs#102
  • Loading branch information
jamestalmage committed Mar 22, 2016
1 parent ad02c32 commit 6f71975
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var inspect = require('util').inspect;
var assert = require('./assert');
var enhanceAssert = require('./enhance-assert');
var globals = require('./globals');
var plur = require('plur');

function Test(title, fn, contextRef, report) {
if (!(this instanceof Test)) {
Expand Down Expand Up @@ -223,7 +224,7 @@ Test.prototype._checkPlanCount = function () {
this._setAssertError(new assert.AssertionError({
actual: this.assertions.length,
expected: this.planCount,
message: 'Assertion count does not match planned',
message: 'Planned for ' + this.planCount + plur(' assertion', this.planCount) + ', but got ' + this.assertions.length + '.',
operator: 'plan'
}));

Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test('run more assertions than planned', function (t) {
t.is(result.reason.name, 'AssertionError');
t.is(result.reason.expected, 2);
t.is(result.reason.actual, 3);
t.match(result.reason.message, /count does not match planned/);
t.match(result.reason.message, /Planned for 2 assertions, but got 3\./);
t.end();
});

Expand Down

0 comments on commit 6f71975

Please sign in to comment.