dom-testing-library: when using `waitForDomChange` on chrome 70 : `setImmediate` is not defined

  • dom-testing-library version: 3.16.1
  • react version: not using react
  • node version: v8.2.0
  • npm (or yarn) 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

Most upvoted comments

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:

That’s a great point @brucou. I’m not sure. I think it’d probably be cool to have a test or two that run in a real browser (using Karma), but I think I’d rather use mocha for two reasons:

  1. I’m personally more familiar with mocha
  2. mocha is a LOT more widely used than Qunit

I don’t think it’s absolutely necessary to have tests that run in a real browser, but if you really would like to do this then you’re welcome to do so 😃

– You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/kentcdodds/dom-testing-library/issues/184#issuecomment-451353595