forked from tape-testing/tape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Fix premature end of tests (and running sibling tests) when tes…
…t includes subtests Fixes tape-testing#222.
- Loading branch information
Showing
5 changed files
with
156 additions
and
32 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 |
---|---|---|
|
@@ -7,5 +7,6 @@ test('parent', function (t) { | |
st.pass('child'); | ||
st.end(); | ||
}); | ||
t.end(); | ||
}, 100); | ||
}) |
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(); | ||
}); | ||
}); | ||
|
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,98 @@ | ||
|
||
var tape = require('../'); | ||
var tap = require('tap'); | ||
var concat = require('concat-stream'); | ||
|
||
var stripFullStack = require('./common').stripFullStack; | ||
|
||
tap.test('plan vs end: plan', function (tt) { | ||
tt.plan(1); | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(function (rows) { | ||
tt.same(rows.toString('utf8'), [ | ||
'TAP version 13', | ||
'# first', | ||
'ok 1 first test', | ||
'ok 2 t not ended', | ||
'ok 3 t has progeny', | ||
'# second', | ||
'ok 4 second test', | ||
'# third', | ||
'ok 5 third test', | ||
'', | ||
'1..5', | ||
'# tests 5', | ||
'# pass 5', | ||
'', | ||
'# ok' | ||
].join('\n') + '\n'); | ||
})); | ||
|
||
test('first', function (t) { | ||
t.plan(4); | ||
setTimeout(function () { | ||
t.ok(1, 'first test'); | ||
t.ok(!t.ended, 't not ended'); | ||
t.ok(t._progeny.length, 't has progeny'); | ||
}, 200); | ||
|
||
t.test('second', function (t) { | ||
t.plan(1); | ||
t.ok(1, 'second test'); | ||
}); | ||
}); | ||
|
||
test('third', function (t) { | ||
t.plan(1); | ||
setTimeout(function () { | ||
t.ok(1, 'third test'); | ||
}, 100); | ||
}); | ||
}); | ||
|
||
tap.test('plan vs end: end', function (tt) { | ||
tt.plan(1); | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(function (rows) { | ||
tt.same(rows.toString('utf8'), [ | ||
'TAP version 13', | ||
'# first', | ||
'ok 1 first test', | ||
'ok 2 t not ended', | ||
'ok 3 t has progeny', | ||
'# second', | ||
'ok 4 second test', | ||
'# third', | ||
'ok 5 third test', | ||
'', | ||
'1..5', | ||
'# tests 5', | ||
'# pass 5', | ||
'', | ||
'# ok' | ||
].join('\n') + '\n'); | ||
})); | ||
|
||
test('first', function (t) { | ||
setTimeout(function () { | ||
t.ok(1, 'first test'); | ||
t.ok(!t.ended, 't not ended'); | ||
t.ok(t._progeny.length, 't has progeny'); | ||
t.end(); | ||
}, 200); | ||
|
||
t.test('second', function (t) { | ||
t.ok(1, 'second test'); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test('third', function (t) { | ||
setTimeout(function () { | ||
t.ok(1, 'third test'); | ||
t.end(); | ||
}, 100); | ||
}); | ||
}); |