map.apps Bundle APIs 4.20.0
    Preparing search index...

    Function waitFor

    • Waits for a resolver to return a value. Continues checking until resolver does not throw an error.

      Type Parameters

      • T

      Parameters

      • resolver: () => T | Promise<T>

        The condition/resolver to be fulfilled. The resolver needs to throw an error to communicate that the value is not yet ready.

      • Optionaloptions: WaitOptions

      Returns Promise<T>

      A promise that transports the value of the resolver.

      An error if the condition is not fulfilled within the specified timeout.

      import { waitFor } from "test-utils/waitFor";

      const result = await waitFor(() => {
      const value = getValue();
      if (value === undefined) {
      throw new Error("Value not ready");
      }
      return value;
      });
      assert.equal(result, "myValue");