-
Notifications
You must be signed in to change notification settings - Fork 470
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
waitForElement
can leave its MutationObserver
running for all future tests
#357
Comments
Hi @RoystonS, Well, I wasn't sure why it was needed either, but I think there's probably something we can do to solve #99 (which is why it was added) and your issue as well. I'm not certain of the best way to go about this. Maybe if we use If you could prototype something that works for your situation and then make a PR for that, we'll give it a look. |
I think this is solved in
Thanks! |
🎉 This issue has been resolved in version 7.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
DOM Testing Library
version: 5.5.0node
version: 10.16.0npm
(oryarn
) version: yarn 1.16.0Relevant code or config:
What you did:
Used
waitForElement
in one test, with the Intern testing framework.What happened:
Every test that calls
waitForElement
causes another DOM MutationObserver to be created, and not cleaned up, and every DOM change causes all priorwaitForElement
predicates to be re-evaluated. The tests get slower and slower.The output:
This shows that, despite the fact that
waitForElement
has completed, it's still listening for DOM changes and still re-evaluating its predicate.Reproduction:
See above. A full repro would require setting up an Intern deployment, which I can do, but it'll take a little longer.
Problem description:
The tests get slower and slower as the number of DOM MutationObservers accumulates, especially as the existing test predicates start to cause exception throws.
Suggested solution:
I'm not sure. Looking at the code, it looks like
waitForElement
usessetImmediate
to queue up the.disconnect
call of the MutationObserver, but it looks like, as my tests run, nothing ever yields sufficiently to allow this callback to run, so the.disconnect
call gets pushed back until all the tests complete. (I'm running on Chrome, which doesn't have nativesetImmediate
, so DTL is using a polyfill which usespostMessage
to simulate the effect.)Removing the
setImmediate
call would cause the MutationObserver to be shut down synchronously, and that would fix this issue, but I don't know why thesetImmediate
call is there: presumably somebody added it for a good reason?The text was updated successfully, but these errors were encountered: