-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain how nested tests work with .plan() #122
Comments
Like you said, This issue is old and I'm sure you figured it out but here's the example simply explained.
|
A potential improvement would be to allow plan to increment the number of things being counted. Thus,
Thoughts? (I will test it locally, since by my naive glance, this is trivial to implement.) EDIT: the other reason I considered this is the case of iterative tests that may want to accumulate tests, as slightly exemplified above. It's far nicer to localize the .plan counts per section. |
+1 I also need it because I run functions that may call sub-functions that plan tap tests. With best regards |
@benfleis @strarsis A workaround for incremental test plans: first_test(t) {
t.plan(2);
testAsyncThing(..., function () {
t.ok(true);
t.notOk(false);
});
}
second_test(t) {
t.plan(1);
testAnotherThing(..., function (randInt) {
t.pass();
if (randInt % 2 === 0) {
t.plan(1)
testOnEven(..., function () {
t.pass();
}
}
});
}
tape.test('parent test clause', function(test) {
test.plan(2)
test.test('nested test', function(t) {
first_test(t)
})
test.test('nexted test 2', function(t) {
second_test(t)
})
}) do let know if this is not helpful, please. |
From experimenting with tape, it seems that an outer test's
.plan()
needs to account for all the inner tests too (even if they have their own plans), and also you need to count botht.test()
and nestedt.plan()
calls as assertions when planning tests. Or maybe I'm doing something wrong?Also I tried first without using
.plan()
, but using.end()
instead, and I couldn't get nesting working at all. A very basic example of nesting would be useful (I know there's one in the ./example dir but it's a very complex example)The text was updated successfully, but these errors were encountered: