File tree 2 files changed +21
-13
lines changed
2 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,23 @@ Test.prototype._end = function (err) {
172
172
Test . prototype . exit = function ( ) {
173
173
var self = this ;
174
174
175
+ function checkAssertLength ( ) {
176
+ if ( self . assertError === undefined && self . planCount !== null && self . planCount !== self . assertPromises . length ) {
177
+ self . _setAssertError ( new assert . AssertionError ( {
178
+ actual : self . assertPromises . length ,
179
+ expected : self . planCount ,
180
+ message : 'Assertion count does not match planned' ,
181
+ operator : 'plan'
182
+ } ) ) ;
183
+
184
+ self . assertError . stack = self . planStack ;
185
+ return false ;
186
+ }
187
+ return true ;
188
+ }
189
+
190
+ checkAssertLength ( ) ;
191
+
175
192
Promise . all ( this . assertPromises )
176
193
. catch ( function ( err ) {
177
194
self . _setAssertError ( err ) ;
@@ -183,16 +200,7 @@ Test.prototype.exit = function () {
183
200
// stop infinite timer
184
201
globals . clearTimeout ( self . _timeout ) ;
185
202
186
- if ( self . assertError === undefined && self . planCount !== null && self . planCount !== self . assertPromises . length ) {
187
- self . _setAssertError ( new assert . AssertionError ( {
188
- actual : self . assertPromises . length ,
189
- expected : self . planCount ,
190
- message : 'Assertion count does not match planned' ,
191
- operator : 'plan'
192
- } ) ) ;
193
-
194
- self . assertError . stack = self . planStack ;
195
- }
203
+ checkAssertLength ( ) ;
196
204
197
205
if ( ! self . ended ) {
198
206
self . ended = true ;
Original file line number Diff line number Diff line change @@ -452,12 +452,12 @@ test('number of assertions matches t.plan when the test exits, but before all pr
452
452
setTimeout ( function ( ) {
453
453
a . throws ( Promise . reject ( new Error ( 'foo' ) ) , 'foo' ) ;
454
454
} , 5 ) ;
455
- } ) . run ( ) . catch ( function ( err ) {
455
+ } ) . run ( ) . catch ( function ( err ) {
456
456
t . is ( err . operator , 'plan' ) ;
457
457
t . is ( err . actual , 3 ) ;
458
458
t . is ( err . expected , 2 ) ;
459
459
t . end ( ) ;
460
- } )
460
+ } ) ;
461
461
} ) ;
462
462
463
463
test ( 'number of assertions doesn\'t t.plan when the test exits, but before all promises resolve another is added' , function ( t ) {
@@ -468,7 +468,7 @@ test('number of assertions doesn\'t t.plan when the test exits, but before all p
468
468
setTimeout ( function ( ) {
469
469
a . throws ( Promise . reject ( new Error ( 'foo' ) ) , 'foo' ) ;
470
470
} , 5 ) ;
471
- } ) . run ( ) . catch ( function ( err ) {
471
+ } ) . run ( ) . catch ( function ( err ) {
472
472
t . is ( err . operator , 'plan' ) ;
473
473
t . is ( err . actual , 2 ) ;
474
474
t . is ( err . expected , 3 ) ;
You can’t perform that action at this time.
0 commit comments