dom-testing-library: when using `waitForDomChange` on chrome 70 : `setImmediate` is not defined
dom-testing-library
version: 3.16.1react
version: not using reactnode
version: v8.2.0npm
(oryarn
) version: v5.3.0
Relevant code or config:
waitForDomChange({ container: root })
What you did:
I ran tests in the browser with QUnit and dom-testing-library.
I tried to use the waitForDomChange
API.
What happened:
Uncaught ReferenceError: setImmediate is not defined
at onDone (dom-testing-library.js:4344)
at MutationObserver.<anonymous> (dom-testing-library.js:4338)
Reproduction:
can’t reproduce in codesandbox. When I try to import {waitForDomChange} from "dom-testing-library"
:
(0 , _domTestingLibrary.waitForDomChange) is not a function
Problem description:
That code from the library use a function which is not defined in chrome :
function waitForDomChange(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$container = _ref.container,
container = _ref$container === void 0 ? getDocument() : _ref$container,
_ref$timeout = _ref.timeout,
timeout = _ref$timeout === void 0 ? 4500 : _ref$timeout,
_ref$mutationObserver = _ref.mutationObserverOptions,
mutationObserverOptions = _ref$mutationObserver === void 0 ? {
subtree: true,
childList: true,
attributes: true,
characterData: true
} : _ref$mutationObserver;
return new Promise(function (resolve, reject) {
var timer = setTimeout(function () {
onDone(new Error('Timed out in waitForDomChange.'), null);
}, timeout);
var observer = newMutationObserver(function (mutationsList) {
onDone(null, mutationsList);
});
observer.observe(container, mutationObserverOptions);
function onDone(error, result) {
clearTimeout(timer);
setImmediate(function () {
return observer.disconnect();
});
if (error) {
reject(error);
} else {
resolve(result);
}
}
});
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (14 by maintainers)
Commits related to this issue
- fix(#184): replacing setImmediate by setTimeour when not defined — committed to brucou/dom-testing-library by deleted user 5 years ago
- fix(#184): replacing setImmediate by setTimeour when not defined — committed to brucou/dom-testing-library by deleted user 5 years ago
- fix(#184): replacing setImmediate by setTimeour when not defined (#188) — committed to testing-library/dom-testing-library by brucou 5 years ago
I used mocha in the past, I am cool with it but I have no appetite to learn karma and the associated config though. PR done.
On 1/4/19, Kent C. Dodds notifications@github.com wrote:
–