How to use the dom-testing-library.waitForElement function in dom-testing-library

To help you get started, we’ve selected a few dom-testing-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netlify / netlify-cms / packages / netlify-cms-media-library-cloudinary / src / __tests__ / index.spec.js View on Github external
};

    /**
     * Mock of the object returned by the Cloudinary createMediaLibrary method.
     */
    mediaLibrary = {
      show: jest.fn(),
      hide: jest.fn(),
    };

    /**
     * We load the Cloudinary library by injecting a script tag to the page
     * head. Initialization waits for the script to load, so here we fake it.
     * This also tests that the expected script is added to the DOM.
     */
    waitForElement(() => {
      const url = 'https://media-library.cloudinary.com/global/all.js';
      return queryHelpers.queryByAttribute('src', document, url);
    }).then(script => {
      cloudinaryScript = script;
      script.onreadystatechange();
    });
  });