You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ waitForElement }=require("dom-testing-library");it("shouldn't hang after succeeding",async()=>{letdidMakeMutation=false;constcreateElement=()=>document.createElement("div");constcontainer=createElement();constmyCallback=()=>{returndidMakeMutation;};constresult=waitForElement(myCallback,{ container });container.appendChild(createElement());didMakeMutation=true;awaitnewPromise((resolve)=>setTimeout(resolve,50));});
What you did:
I'm trying to use waitForElement to wait until an element is created in the dom.
What happened:
I found that my test is passing, but the test runner (mocha) doesn't exit - it gets into infinite setTimeout loop.
The test succeeds, but the test runner (mocha) doesn't ever exit, because waitForElement gets into infinite setTimeout loop.
I think the problem is that waitForElement calls observer.disconnect() from the onMutation() -> onDone() callback. MutationObserver, after calling the onMutation() callback, immediately recreates the listener, and then gets into the infinite setTimeout loop.
Suggested solution:
waitForElement should somehow call disconnect()afterMutationObserver recreates the listener.
The text was updated successfully, but these errors were encountered:
dom-testing-library
version: 3.5.1node
version: 8.11.2npm
(oryarn
) version: 5.6.0Relevant code or config:
What you did:
I'm trying to use
waitForElement
to wait until an element is created in the dom.What happened:
I found that my test is passing, but the test runner (mocha) doesn't exit - it gets into infinite setTimeout loop.
Reproduction:
Repo: https://github.com/grigasp/dom-testing-library-waitforelement-issue
npm install npm run test
Problem description:
The test succeeds, but the test runner (mocha) doesn't ever exit, because
waitForElement
gets into infinitesetTimeout
loop.I think the problem is that
waitForElement
callsobserver.disconnect()
from theonMutation()
->onDone()
callback.MutationObserver
, after calling theonMutation()
callback, immediately recreates the listener, and then gets into the infinitesetTimeout
loop.Suggested solution:
waitForElement
should somehow calldisconnect()
afterMutationObserver
recreates the listener.The text was updated successfully, but these errors were encountered: