avajs/ava

can't handle timeout exception #2939

alisa4y posted onGitHub

hi I had code which throws error like this:

test("throws", async (t) => { const e = await t.throwsAsync(async () => { setTimeout(() => { throw new Error("error"); }, 0); await timeout(10); }); }); function timeout(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }

it just can't handle it


Please spend some more time on the issue.

What happens? What did you expect?

posted by sindresorhus almost 3 years ago

.throwsAsync() cannot catch an error thrown inside setTimeout. That's just how JavaScript works and has nothing to do with AVA.

posted by sindresorhus almost 3 years ago

.throwsAsync() cannot catch an error thrown inside setTimeout. That's just how JavaScript works and has nothing to do with AVA.

yes that's true :) but I expected some how ava could do it :D

posted by alisa4y almost 3 years ago

Fund this Issue

$0.00
Funded

Pull requests