-
-
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
Test using async/await does not end #358
Comments
You can't really pass an async function to tape because tape does not do anything with the promise it returns. You might have slightly more success though using |
I don't understand. Why the test passes, but
I tried that, but the problem didn't resolve. |
Furthermore, if I add more async tests, i.e.:
only the last one doesn't finish. The others pass and finish correctly. |
An async function is just sugar for a function that returns a promise. Tape does not do anything special with promises. Without a synchronous call to You need to only pass a function to tape, not an async function; unless you're willing to jump through all the hoops required, which includes calling .plan before the first await, in every test. |
@ljharb As I said, using |
Ah - the likely issue is that one of your tests has a rejected promise, and that's causing the test('async test 1', async (assert) => {
assert.plan(1);
try {
const res = await someAsyncCall();
assert.equal(res, 0);
assert.end();
} catch (e) {
assert.fail(e);
}
}); Using |
Tape supports async since version v5This issue is about Tape v4, but since v5 Tape actually does support Promises / async/await. |
I looked at many issues in this repo, such as #222, #262, etc. but I still don't know why the following test does not end:
when
connectToDatabase
is an async function.When I run the test, I get the following result:
but the test does not finish. Shouldn't
assert.end()
finish the test after promise resolution? What is the reason behind this behavior?The text was updated successfully, but these errors were encountered: