Skip to content
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

t.end not honored #264

Closed
cdaringe opened this issue Feb 23, 2016 · 3 comments · Fixed by #489
Closed

t.end not honored #264

cdaringe opened this issue Feb 23, 2016 · 3 comments · Fixed by #489

Comments

@cdaringe
Copy link

var test = require('tape');

test('something', t => {
    t.end();
    t.ok('bananas');
    t.pass('pass');
});

==>

cdieringer@Snapper-osx:~/node/test-tape-end$ node index.js
TAP version 13
# something
ok 1 (unnamed assert)
ok 2 pass

1..2
# tests 2
# pass  2

# ok

this is unexpected. i would expect t.end not not permit subsequent tests, or otherwise error on them.

@ljharb
Copy link
Collaborator

ljharb commented Feb 23, 2016

There'd be no way in JS to not permit subsequent tests in a containing function from a function called within it - but I agree that it should error out on adding new tests after end is called. @substack, @Raynos, any concerns about tightening this up?

@yoshuawuyts
Copy link

I think disallowing subsequent requests is reasonable.

@jtlapp
Copy link
Contributor

jtlapp commented Aug 3, 2016

Looking into this now, I could only find two detrimental effects for assertions that follow t.end. They only apply to asynchronous assertions that follow t.end and to assertions in nested tests that follow t.end:

  1. If the harness is created with autoclose false (which is the default), these assertions may appear out of order. Assertions within nested tests will properly appear under the nested test comment heading, but those not within nested tests may appear under other test headings.
  2. If the harness is created with autoclose true and the output stream closes before the assertions run, the results of the assertions will not make it into the output. If the assertions run before the stream closes, (1) applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants