Skip to content

Commit 75ca556

Browse files
committed
add Test.prototype._checkPlanCount()
1 parent c7b0154 commit 75ca556

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lib/test.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,22 @@ Test.prototype._end = function (err) {
169169
this.exit();
170170
};
171171

172-
Test.prototype.exit = function () {
173-
var self = this;
174-
175-
function checkAssertLength() {
176-
if (self.assertError === undefined && self.planCount !== null && self.planCount !== self.assertions.length) {
177-
self._setAssertError(new assert.AssertionError({
178-
actual: self.assertions.length,
179-
expected: self.planCount,
180-
message: 'Assertion count does not match planned',
181-
operator: 'plan'
182-
}));
172+
Test.prototype._checkPlanCount = function () {
173+
if (this.assertError === undefined && this.planCount !== null && this.planCount !== this.assertions.length) {
174+
this._setAssertError(new assert.AssertionError({
175+
actual: this.assertions.length,
176+
expected: this.planCount,
177+
message: 'Assertion count does not match planned',
178+
operator: 'plan'
179+
}));
183180

184-
self.assertError.stack = self.planStack;
185-
}
181+
this.assertError.stack = this.planStack;
186182
}
183+
};
184+
185+
Test.prototype.exit = function () {
187186

188-
checkAssertLength();
187+
this._checkPlanCount();
189188

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

201-
checkAssertLength();
200+
this._checkPlanCount();
202201

203202
if (!self.ended) {
204203
self.ended = true;

0 commit comments

Comments
 (0)