Documentation

expectOutputAsync()

Waits for output to be rendered, that matches the provided selection filter(s).

expectOutputAsync(
select: OutputSelectFilter & {
timeout?: number;
},
...nested: OutputSelectFilter[]
): Promise<OutputAssertion>;

Summary

This method regularly polls all rendered output, and attempts to match the specified filter(s). As soon as one or more elements match and no further rendering is scheduled to take place, the resulting promise is resolved.

This method can be used to validate new output, and find the subset of output elements that match the given filter(s). Any element in the current output may be matched, including container content; but not content within a matching container (i.e. only the highest-level elements that match a selection filter).

The first argument may include a timeout property, in milliseconds. If the specified timeout is reached, the promise is rejected. If no timeout is specified, a timeout value of 200ms is used.

Notes

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

Parameters

Return value

A promise for an OutputAssertion instance for the matched element(s). The promise is rejected if a timeout occurs.

Examples

describe("My scope", () => {
  test("Expect a button", async (t) => {
    let app = useTestContext();
    // ... render a view
    // now wait for a Confirm button:
    await app.renderer.expectOutputAsync({
      type: "button",
      text: "Confirm"
    });
});

Related