Docs (4.0.0)
class TestRenderer method

expectOutputAsync

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

expectOutputAsync(timeout: number, ...select: OutputSelectFilter[]): Promise<OutputAssertion>

Summary

This method regularly polls all rendered output, and attempts to match the given 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). 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
  • select — A list of filters to find matching output elements. The first filter is applied, then the second one on all content of matching elements, and so on. Note that multiple elements may be found, which may not be part of the same container.

Return value

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

Example

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(
      100,
      { type: "button", text: "Confirm" }
    );
});

Related