-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are two bugs here, one a matter of correctness, the other a matter of changing behavior between plan and end (1) without plan(), the parent test would be _ended prematurely as soon as all queued subtests completed, and sibling tests of the parent would run (2) plan() runs all assertions in the plan, then starts running subtests. end() ran subtests on nextTick after creation (see Test.prototype.test), so the relative ordering of asserts vs subtests could change with async asserts. New behavior without a plan is to only start subtests after t.end().
- Loading branch information
Showing
2 changed files
with
41 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var test = require('../'); | ||
|
||
test('async end', function(t) { | ||
setTimeout(function() { | ||
t.assert(!t.ended, '!t.ended'); | ||
t.end(); | ||
}, 200); | ||
}); | ||
|
||
test('async end with subtest', function(t) { | ||
setTimeout(function() { | ||
t.assert(!t.ended, '!t.ended'); | ||
t.end(); | ||
}, 200); | ||
|
||
t.test('subtest', function(g) { | ||
g.assert(!t.ended, 'subtest !t.ended'); | ||
g.end(); | ||
}); | ||
}); | ||
|