-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Version
30.0.0-beta.5
Steps to reproduce
I am still working on getting a useful repro case. In the meantime, here are some details about what my tests look like.
I am using Jest to test a next.js API using a custom express server. I have a withServer
helper that I use in these API tests that starts the express/next.js server and gets it listening for requests in a beforeAll
. Then in an afterAll
, the server is closed.
The tests are using the supertest
package to make the requests against the API.
When I run one of these tests on its own, it works fine. But if I run more than one test that sets up this server, I end up with problems in the later tests. So one key to reproducing this is to have multiple test files that set up the server and then to run them sequentially.
Expected behavior
I expect my tests to pass.
Actual behavior
The second test file that uses our withServer
helper ends up logging TypeError: Class constructor AsyncLocalStorage cannot be invoked without 'new'
repeatedly and then times out after 10 seconds. At the end of the tests, this is logged:
Jest did not exit one second after the test run has completed.
'This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Running with --detectOpenHandles
doesn't detect any open handles.
Additional context
Since this happens only when there is more than one test file and since it does not happen with the alpha releases (similar qualities as #15632 for instance), it seems like it could possibly be related to #15215 though it seems like it needs a different fix than #15636.
Environment
System:
OS: macOS 15.4.1
CPU: (8) arm64 Apple M3
Binaries:
Node: 22.16.0 - ~/.local/share/mise/installs/node/22.16.0/bin/node
Yarn: 1.22.22 - ~/.local/share/mise/installs/yarn/1.22.22/bin/yarn
npm: 10.9.2 - ~/.local/share/mise/installs/node/22.16.0/bin/npm
npmPackages:
jest: ^30.0.0-beta.5 => 30.0.0-beta.5