Docs (4.0.0)
class TestRenderer method

expectMessageDialogAsync

Waits for an alert or confirmation dialog to be rendered, that contains the provided label(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

  • timeout — The number of milliseconds to wait for matching output to be rendered
  • match — A list of strings or regular expressions to validate matching label(s) on the message dialog.

Return value

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

Example

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