Documentation

expectMessageDialogAsync()

Waits for an alert or confirmation dialog to be rendered, that contains the provided text(s).

expectMessageDialogAsync(
timeout?: number,
...match: Array<string | RegExp>
): Promise<RenderedTestMessageDialog>;

Summary

This method regularly polls all rendered output, and attempts to find a message dialog. As soon as one is found, the resulting promise is resolved to an instance of RenderedTestMessageDialog.

The returned object can be used to validate dialog contents, and to click its buttons (asynchronously).

If the specified timeout is reached, the promise is rejected.

Notes

Note
This method is asynchronous, and must be await-ed in a test function.

Parameters

Return value

A promise for a RenderedTestMessageDialog instance. The promise is rejected if a timeout occurs.

Examples

describe("My scope", () => {
  test("Cancel a confirmation dialog", async (t) => {
    let app = useTestContext();
    // ...
    let p = app.showConfirmDialog("Are you sure?");
    await (
      await app.renderer.expectMessageDialogAsync(100, /sure/)
    ).cancelAsync();
    let result = await p;
    expect(result).toBe(false);
  });
});

Related