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
- To avoid casting app to get to the TestRenderer instance, use the expectMessageDialogAsync() method instead.
Note
This method is asynchronous, and must beawait-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 text(s) on the message dialog.
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
class TestRenderer
A class that represents an in-memory application render context.
