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

Async: supported or not? Change docs? #592

Closed
Download opened this issue Mar 21, 2023 · 2 comments
Closed

Async: supported or not? Change docs? #592

Download opened this issue Mar 21, 2023 · 2 comments

Comments

@Download
Copy link

I am confused whether async is supported in Tape.

In the example in the README I see this:

test('test using promises', async function (t) {
    const result = await someAsyncThing();
    t.ok(result);
});

This to me strongly suggests Tape supports async.
Though I see no t.plan() or t.end(), which confuses me...
And indeed my test does not end... Even not after adding a call to t.end()...

So I perused the issue list where I found this issue:

Test using async/await does not end #358

In there, I see this comment by the author:

You can't really pass an async function to tape because tape does not do anything with the promise it returns.

I guess the author knows what he is talking about. But this leaves me wondering. Why explicitly give an example of an async test when it is not really supported? Should we maybe remove that example from the docs?

@ljharb
Copy link
Collaborator

ljharb commented Mar 21, 2023

That comment described tape v4 - v5 supports a returned promise from the function, which means it supports async function. What version are you using?

There's no need for t.end() because the promise itself fulfilling notifies tape when the test is over.

@Download
Copy link
Author

Ah! That clarifies a lot!

In the mean time I have been doing some testing and it seems that you are right that it is supported as another async function that only calls setTimeout does finish as expected. So the issue seems to be in my code... as usual.

UPDATE

Did some more testing and figured it out. It has nothing to do with tape. The issue was that knex keeps the process alive unless I explictly call destroy on it or use process.exit. Thanks for your reply!

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

No branches or pull requests

2 participants