Skip to content

Commit

Permalink
add Test.prototype._checkPlanCount()
Browse files Browse the repository at this point in the history
  • Loading branch information
ariporad committed Dec 24, 2015
1 parent c7b0154 commit 75ca556
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,22 @@ Test.prototype._end = function (err) {
this.exit();
};

Test.prototype.exit = function () {
var self = this;

function checkAssertLength() {
if (self.assertError === undefined && self.planCount !== null && self.planCount !== self.assertions.length) {
self._setAssertError(new assert.AssertionError({
actual: self.assertions.length,
expected: self.planCount,
message: 'Assertion count does not match planned',
operator: 'plan'
}));
Test.prototype._checkPlanCount = function () {
if (this.assertError === undefined && this.planCount !== null && this.planCount !== this.assertions.length) {
this._setAssertError(new assert.AssertionError({
actual: this.assertions.length,
expected: this.planCount,
message: 'Assertion count does not match planned',
operator: 'plan'
}));

self.assertError.stack = self.planStack;
}
this.assertError.stack = this.planStack;
}
};

Test.prototype.exit = function () {

checkAssertLength();
this._checkPlanCount();

Promise.all(this.assertions)
.catch(function (err) {
Expand All @@ -198,7 +197,7 @@ Test.prototype.exit = function () {
// stop infinite timer
globals.clearTimeout(self._timeout);

checkAssertLength();
this._checkPlanCount();

if (!self.ended) {
self.ended = true;
Expand Down

0 comments on commit 75ca556

Please sign in to comment.