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
{{ message }}
Repository navigation
[Test Runner] Dynamic tests yielding "test did not finish before its parent and was cancelled" #54163
Darwin Watt.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
Subsystem
Test Runner
What steps will reproduce the bug?
I'm not sure if I can provide a test without any external libraries, theres a large chance this is something related to my code as well, but here's the bit I'm testing
importtesterWrap,{AxiosInstance}from'axiosist';importassertfrom'node:assert';import{after,before,describe,it}from'node:test';import{env}from'../../src/config';import{initApp}from'../../src/init';import{router}from'../../src/module/router';import{testAccount}from'./fixtures/test-account';describe('Module Test',()=>{
let api: AxiosInstance;before(async()=>{constserver=awaitinitApp(env);api=testerWrap(server);});describe('Public routes',()=>{it('should return 401 for calls without authentication',()=>{for(constlayerofrouter.stack){constpath=layer.route?.path.replace(':id','someid');constmethods=Object.keys(layer?.route?.methods??{});if(path&&methods.length>0){for(constmethodofmethods){it(`[${method}] at ${path}`,async()=>{constresponse=awaitapi[method](`/v1/module/${path}`);assert.strictEqual(response.status,401);});}}}});});
How often does it reproduce? Is there a required condition?
This is my current script for running the tests: node --env-file=.env --import=tsx --test *.test it's been consistently failing up until now, but it has worked before without any code changes, so I'm not sure what could be happening
What is the expected behavior? Why is that the expected behavior?
Tests would run dynamically
What do you see instead?
All tests fail with 'test did not finish before its parent and was cancelled'
Additional information
Again, I'm not sure if this is a problem related to my coding (which most likely is) or some promise not being handled in the runner. I've tried removing and modifying several parts but it keeps early exiting, it seems like the promises are being resolved before the assertion is made.
Activity
cjihrig commentedon Aug 1, 2024
Nested tests need to be awaited. I think that should fix your problem.
In Node 23 we are considering removing this restriction and having tests/suites automatically wait for any subtests (#54011).
khaosdoctor commentedon Aug 2, 2024
@cjihrig makes a lot of sense, it did solve the problem, if I can help in any of these implementations I'd love to