Function: within()
within(
container):BoundQueries
Defined in: within.ts:31
Creates scoped query methods for a container widget.
Use this to query within a specific section of your UI rather than the entire application.
Parameters
| Parameter | Type | Description |
|---|---|---|
container | Widget | The widget to scope queries to |
Returns
Object with query methods bound to the container
Example
import { render, within } from "@gtkx/testing";
test("scoped queries", async () => {
await render(<MyPage />);
const sidebar = await screen.findByRole(Gtk.AccessibleRole.NAVIGATION);
const sidebarQueries = within(sidebar);
// Only searches within the sidebar
const navButton = await sidebarQueries.findByRole(Gtk.AccessibleRole.BUTTON);
});
See
screen for global queries