waitForElementsToBeRemoved function Async

Future<void> waitForElementsToBeRemoved(
  1. List<Node> callback(
    1. {Node container,
    2. Duration timeout,
    3. Duration interval = const Duration(milliseconds: 50),
    4. QueryTimeoutFn onTimeout,
    5. MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}

    Waits for the removal of all the elements returned from the callback to be removed from the DOM.

    To wait for a single element to be removed, use waitForElementToBeRemoved.



    An ancestor DOM node of the elements you return from callback. This node will have a MutationObserver attached to it.

    Defaults to document.body.


    How long to wait for the node to appear in the DOM before throwing a TestFailure, defaulting to 1000ms.


    How often the callback is called, defaulting to 50ms.


    Is called if the timeout duration passes before the node is found in the DOM, and can be used to customize a TestFailure message.


    The default values are:

    {subtree: true, childList: true, attributes: true, characterData: true}

    which will detect additions and removals of child elements (including text nodes) in the container and any of its descendants. It will also detect attribute changes. When any of those changes occur, it will re-run the callback.


    Future<void> waitForElementsToBeRemoved(
      List<Node> Function() callback, {
      Node container,
      Duration timeout,
      Duration interval = const Duration(milliseconds: 50),
      QueryTimeoutFn onTimeout,
      MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions,
    }) async {
      container ??= document.body;
      final els = callback();
      if (els == null || els.isEmpty) {
        throw TestingLibraryElementError('The callback must return one or more non-null Elements.');
      for (final el in els) {
        if (!container.contains(el)) {
          throw TestingLibraryElementError(
              'One of the elements returned from the callback was not present in the container at the time waitForElementsToBeRemoved() was called:\n\n'
      await Future.wait(els.map((el) => waitForElementToBeRemoved(() => el,
          container: container,
          timeout: timeout,
          interval: interval,
          onTimeout: onTimeout,
          mutationObserverOptions: mutationObserverOptions)));