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
- To avoid casting app to get to the TestRenderer instance, use the expectOutputAsync() method instead.
Note
This method is asynchronous, and must beawait-ed in a test function.
Parameters
- 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. The first filter may contain a
timeoutproperty as explained above.
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
class TestRenderer
A class that represents an in-memory application render context.
