Zora pta doesn't report anything if there are any pending tests that don't wait for any events
wokalski opened this issue · comments
I don't have a minimal zora repro but it's obvious from this:
// x.mjs
Promise.all([Promise.resolve(), new Promise(() => {})]).then(() => console.log("hello"))
run node x.mjs
and you won't see hello but the program will terminate successfully. In the case of zora, you will see the program terminate but it won't report anything. Ideally (a 10 star experience) the test runner would execute normally and report and then it would tell me "hey, this and this test is still pending but it's not waiting for anything. It's most likely a bug".
Its the opposire of late assertion. Create a test that returns new Promise(() => {}).then(() => t.equal(0, 1))
Oh I see. Thanks. I'am getting a look at it
Apparently, finding a broken promise is quite a thing
The only easy way I can think of (which would be cross platform) is to make the user spec function compete with a timeout function and throw if the timeout wins.
something like this PR
Here's what I'd do:
- When you register tests add them to a map
- When they conclude, remove them from the map
- On
'exit'
hook, print the ones that are not concluded - Profit
You don't actually need to know what the state of the promise is, you can solve it reliably on the framework level.
Actually that's not that simple. There is only an exit hook in a nodejs environment (and Deno) but not in the browser. You can't either add this check after the reporting stream as it is simply broken (the code after won't run).
I think I'll rather go for test timeout which adds anyway a nice to have assertion