You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you're trying to do
I have a test which is writing debug logs to the console but not making any asserts. The timeout on that test is triggering that the test failed, but not actually stopping the test run so ava never exits.
Timeouts can also be set individually for each test. These timeouts are reset each time an assertion is made. The test fails if it takes more than ms for an assertion to be made or the test to complete.
What happened
$ npm test will-not-stop.js
> test
> ava will-not-stop.js
0s
1s
2s
3s
4s
✘ [fail]: will not stop stop after 5s
5s
6s
7s
...
62s
^C
✘ Exiting due to SIGINT
Failed to exit when running will-not-stop.js
─
will not stop
Error: stop after 5s
Error: stop after 5s
at Timeout.<anonymous> (file:///Users/matthew/spikes/repro-ava-timeout/node_modules/ava/lib/test.js:439:24)
at listOnTimeout (node:internal/timers:594:17)
at process.processTimers (node:internal/timers:529:7)
─
1 test failed
What you expected to happen
I expected the test to exit after it was marked as having failed, as in this example:
$ npm test will-stop.js
> test
> ava will-stop.js
✘ [fail]: will stop stop after 5s
✘ Timed out while running tests
Failed to exit when running will-stop.js
─
will stop
Error: stop after 5s
Error: stop after 5s
at Timeout.<anonymous> (file:///Users/matthew/spikes/repro-ava-timeout/node_modules/ava/lib/test.js:439:24)
at listOnTimeout (node:internal/timers:594:17)
at process.processTimers (node:internal/timers:529:7)
─
1 test failed
Sample Code:
Run npm init ava to create a skeleton project (done on 04/03/2025, ava v6.2.0)
Add will-not-stop.js
importtestfrom"ava";test("will not stop",async(t)=>{t.timeout(5_000,"stop after 5s");for(leti=0;;++i){console.log(`${i}s`);awaitnewPromise((resolve)=>setTimeout(resolve,1000));}});
Add will-stop.js (same as will-not-stop but with the write call commented out)
importtestfrom"ava";test("will not stop",async(t)=>{t.timeout(5_000,"stop after 5s");for(leti=0;;++i){// console.log(`${i}s`);awaitnewPromise((resolve)=>setTimeout(resolve,1000));}});
The text was updated successfully, but these errors were encountered:
For future readers, the issue here is that AVA believes the test worker is still active, but only because it's writing to stdout. It therefore doesn't exit. The lack of exiting is because the timeout itself is keeping the worker alive, but AVA should have detected the worker not exiting.
Please provide details about:
I have a test which is writing debug logs to the console but not making any asserts. The timeout on that test is triggering that the test failed, but not actually stopping the test run so ava never exits.
I expected the test to exit after it was marked as having failed, as in this example:
Sample Code:
npm init ava
to create a skeleton project (done on 04/03/2025, ava v6.2.0)The text was updated successfully, but these errors were encountered: