-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: toMatchObject on document.body makes Jest freeze #14133
Comments
we have same issues https://github.com/microsoft/fluentui/pull/28032/files#r1211527953 Besides that some matches started failing with following error |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
huh - this is a weird one... Does it happen with multiple different JSDOM versions? |
Similar to #14375. Could someone double check if it makes sense what I wrote in #14375 (comment) |
@mrazauskas, document.body.ownerDocument.defaultView.globalThis === globalThis // true
document.body.ownerDocument.defaultView.globalThis === globalThis.globalThis // true And this will happen with any DOM Node as one of the |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
29.5.0
Steps to reproduce
yarn
.yarn test
.about to expect
in your terminal, but notdone expecting
.Expected behavior
I expect the assertion to pass and the test to finish running.
Actual behavior
Jest uses a lot of CPU, and the
expect(document.body).toMatchObject(document.body);
line never seems to finish.If you try to exit Jest by pressing Ctrl+C, the process might still be running and using a lot of CPU, and not exit unless you kill it. This does not always happen though.
Additional context
I am able to reproduce this in Jest 29.2.2 (with jest-environment-jsdom@29.2.2) and Jest 29.5.0 (with jest-environment-jsdom@29.5.0). I did not try any other versions.
If you want a more realistic example of a real-world situation where this can happen, you can change the assertion to something like
expect({ element: document.body }).toMatchObject({ element: document.body });
, but this is not necessary.My real-world test suite passes in Jest 29.2.2, but freezes in Jest 29.5.0, for reasons I haven't figured out.
If I remove one or more of the buttons, Jest takes a somewhat long time, then shows output like this:
Environment
The text was updated successfully, but these errors were encountered: