-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Version
30.0.0-beta
Steps to reproduce
- Use https://github.com/faulpeltz/jest-issue-repro
- Run jest
Expected behavior
Tests pass
Actual behavior
The test which is executed after the first fails with:
TypeError: Value of "this" must be of type EventTarget
Note that using worker_threads
in my example is just one of many Node-builtin locations where this causes issues (in my actual test suite), mostly related to streams, child processes, etc.
Additional context
The issue cannot be reproduced in alpha.7
, and I was able to track it down to this commit: 999bb65
This introduces a cleanup of the global object but it looks like it cleans up way to much - in my example EventTarget is removed after the first test file, causing the second to fail.
In this example this is caused by the cleanup of Symbol(nodejs.event_target)
which is only defined after the initial setup phase and then is cleaned up - and probably other things as well. It seems that many Node builtin APIs lazily intialize some symbol properties on the global object when first used, and cleaning those up is probably unsafe.
If symbol-properties are skipped for cleanup, then things work normally
Environment
Linux Mint, x64, Node v22.16.0