The enzyme-adapter-react-16 package appears to use the global Worker class and set up a MessagePort. Node 16 has a native global Worker class. When running mocha, the process never terminates. In debugging with wtfnode, the cause was an open MessagePort handle. Just importing the library seems to be enough to cause the hang; you don't even have to use the adapter.
To work around this, I figured out that if I set up jsdom beforehand and reassign global.Worker to window.Worker. That seems to resolve the problem.
enzyme-adapter-react-16 should more gracefully run within a node 16 environment.
Current behavior
Importing enzyme-adapter-react-16 in a unit test suite causes test runner process to hang (observed with mocha)
The
enzyme-adapter-react-16
package appears to use the globalWorker
class and set up aMessagePort
. Node 16 has a native globalWorker
class. When running mocha, the process never terminates. In debugging withwtfnode
, the cause was an openMessagePort
handle. Just importing the library seems to be enough to cause the hang; you don't even have to use the adapter.To work around this, I figured out that if I set up
jsdom
beforehand and reassignglobal.Worker
towindow.Worker
. That seems to resolve the problem.enzyme-adapter-react-16
should more gracefully run within a node 16 environment.Current behavior
Importing
enzyme-adapter-react-16
in a unit test suite causes test runner process to hang (observed withmocha
)Expected behavior
Processes should not hang
Version
Adapter