From 6f71975b11119df9997d19ca7c87927019e30e18 Mon Sep 17 00:00:00 2001 From: James Talmage Date: Tue, 22 Mar 2016 01:26:09 -0400 Subject: [PATCH] Print the planned and actual assertion count when incorrect. Fixes #102 --- lib/test.js | 3 ++- test/test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/test.js b/lib/test.js index 7fb034a95f..b4906f37a2 100644 --- a/lib/test.js +++ b/lib/test.js @@ -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)) { @@ -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' })); diff --git a/test/test.js b/test/test.js index fa2922371d..68db6dbe1c 100644 --- a/test/test.js +++ b/test/test.js @@ -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(); });