API Reference / @gtkx/testing
@gtkx/testing
Namespaces
| Namespace | Description |
|---|---|
| prettyFormat | - |
Type Aliases
| Type Alias | Description |
|---|---|
| BoundQueries | The set of built-in queries (getBy, findBy, queryBy, and their All variants) bound to a specific container. |
| BuiltQueries | The variants derived from one queryAllBy function, in the order DOM Testing Library returns them. |
| ByRoleOptions | Options for role queries: an accessible name matcher plus accessible state and value constraints. |
| ByRoleValue | Constraints on a widget's numeric range value used by role queries. The numbers come from the accessibility tree and match within 0.001, the resolution GTK keeps them to. |
| ClassExpectation | The expected value for a style class: an exact class name or a regular expression. |
| Config | Global configuration for the testing harness, controlling query behavior, error formatting, and the timeouts used by async utilities and actionability checks. |
| ConfigFn | Function form of a configuration update: receives the current config and returns the fields to override. |
| Container | A scope that queries and traversal can run against: a widget, an event controller, a layout manager, a list item or header, an application, or the sentinel representing all current toplevel windows. |
| ControllerConstructor | An event controller class that can be constructed without arguments, such as Gtk.GestureClick. |
| DragOffset | A drag offset relative to the drag start point. |
| DragOptions | Options for a drag gesture: the starting point, the number of interpolated drag updates, or explicit intermediate offsets emitted before the final one. |
| DropContent | The value delivered to a drop target: a primitive (converted to a GObject.Value) or an explicit GObject.Value. |
| DropOptions | Options for a drop: the drop coordinates within the target. |
| Matcher | A value used to match widget text: a string or number, a regular expression, or a custom MatcherFunction. |
| MatcherFunction | A custom matcher predicate: given a candidate widget's normalized text content and the widget itself, returns whether it matches. |
| MatcherOptions | Options controlling text matching and, for asynchronous queries, polling behavior. |
| Method | The query family a suggestion targets. |
| MissingErrorBuilder | Builds the error thrown when a query that requires a match finds none. |
| MultipleErrorBuilder | Builds the error thrown when a single-match query finds more than one widget. |
| NormalizerFn | Normalizes a widget's text before it is compared against a matcher. |
| NormalizerOptions | Options controlling the default text normalizer. |
| PointerInput | A pointer action token, as in Testing Library: a full click ([MouseLeft], [MouseRight], [MouseMiddle]), a button press ([MouseLeft>]) or a button release ([/MouseLeft]). click, down and up are the left button. The left button clicks the widget as click does; the right and middle buttons reach only the click gestures listening for them, such as a GtkGestureClick with button={Gdk.BUTTON_SECONDARY} that opens a context menu. |
| PrettyWidgetOptions | Options controlling how a widget tree is rendered to a string by prettyWidget and logWidget. |
| QueryAllBy | The queryAllBy function a query family is built from, taking the scope to search followed by the family's own matcher arguments. Its name determines the family name, so queryAllByTestId builds a TestId family. |
| QueryHelpers | The helpers used to build custom queries, bundled the way DOM Testing Library exposes them. |
| RenderHookOptions | Options for renderHook: an optional wrapper and the initial props (required unless the props type permits undefined). |
| RenderHookResult | The result of renderHook: the latest hook return value plus functions to rerender with new props and to unmount. |
| RenderOptions | Options for render: the container and base element to mount into, an optional wrapper, React behavior toggles, error callbacks, and custom queries to bind. |
| RenderResult | The result of a render call: queries scoped to the rendered tree, debug utilities, and controls for updating or tearing down the render. |
| Screen | The global screen object's shape: built-in queries scoped to the current toplevels, plus debug utilities. |
| ScreenshotOptions | Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and a file to write the PNG to. |
| ScreenshotResult | A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. |
| ScrollDelta | A scroll distance in pixels along each axis. |
| Suggestion | A suggested query for reaching a widget, including its family, variant, method name, and a toString that renders the full call. |
| TabOptions | Options for userEvent.tab. |
| TextContentOptions | Options controlling how toHaveTextContent normalizes the text it reads. |
| TextExpectation | The expected value for a text matcher: an exact string or a regular expression. |
| TypeOptions | Options for userEvent.type. |
| UserEvent | User interactions exposed by userEvent. |
| UserEventOptions | Options shared by every helper on a UserEvent instance. |
| Variant | The query variant a suggestion targets. |
| WaitForOptions | Options controlling how asynchronous queries and waits poll for a condition. |
| WidgetEvent | A signal emission built but not yet delivered. GObject has no event object to construct, so this records the target, signal, and arguments fireEvent will emit. |
| WidgetType | A widget class usable as a query's as constraint, such as Gtk.Button. Abstract classes and generated GInterface pseudo-classes that extend Gtk.Accessible are accepted. |
| WrapperComponent | A React component that wraps rendered content, receiving it as its children. |
Variables
| Variable | Description |
|---|---|
| act | Runs a callback inside React's act environment, flushing pending state updates and effects, and resolves once the work has settled. |
| findAllByDisplayValue | Finds all mapped widgets with a display value. |
| findAllByLabelText | Finds all mapped widgets with label text. |
| findAllByName | Finds all mapped widgets with a GTK name. |
| findAllByPlaceholderText | Finds all mapped widgets with placeholder text. |
| findAllByRole | Finds all mapped widgets with an accessible role. |
| findAllByText | Finds all mapped widgets with rendered text. |
| findByDisplayValue | Finds one mapped widget by display value. |
| findByLabelText | Finds one mapped widget by label text. |
| findByName | Finds one mapped widget by GTK name. |
| findByPlaceholderText | Finds one mapped widget by placeholder text. |
| findByRole | Finds one mapped widget by accessible role. |
| findByText | Finds one mapped widget by rendered text. |
| getAllByDisplayValue | Gets all mapped widgets with a display value. |
| getAllByLabelText | Gets all mapped widgets with label text. |
| getAllByName | Gets all mapped widgets with a GTK name. |
| getAllByPlaceholderText | Gets all mapped widgets with placeholder text. |
| getAllByRole | Gets all mapped widgets with an accessible role. |
| getAllByText | Gets all mapped widgets with rendered text. |
| getByDisplayValue | Gets one mapped widget by display value. |
| getByLabelText | Gets one mapped widget by label text. |
| getByName | Gets one mapped widget by GTK name. |
| getByPlaceholderText | Gets one mapped widget by placeholder text. |
| getByRole | Gets one mapped widget by accessible role. |
| getByText | Gets one mapped widget by rendered text. |
| matchers | The widget assertion matchers keyed by name, suitable for passing to expect.extend. |
| queryByDisplayValue | Queries one mapped widget by display value. |
| queryByLabelText | Queries one mapped widget by label text. |
| queryByName | Queries one mapped widget by GTK name. |
| queryByPlaceholderText | Queries one mapped widget by placeholder text. |
| queryByRole | Queries one mapped widget by accessible role. |
| queryByText | Queries one mapped widget by rendered text. |
| queryHelpers | The query-building helpers, bundled so they can be reached under a single import. |
| screen | Queries and debug utilities bound to the most recent render, scoped to the current toplevel windows. Accessing it before any render throws. |
| userEvent | User interactions that dispatch GTK events and gestures. |
Functions
| Function | Description |
|---|---|
| buildQueries | Builds a query family from queryAllBy, following DOM Testing Library's buildQueries. Query suggestions use queryAllBy.name as the family name. |
| cleanup | Unmounts every active render, quits the applications those renders started, and runs all registered cleanup callbacks, resetting the screen, the clipboard and the input the default userEvent still holds. Called automatically after each test. |
| computeHeadingLevel | Returns the heading or hierarchy level GTK reports for a widget, or undefined when it declares none. |
| configure | Merges the given overrides into the global testing configuration. |
| createEvent | Records a signal emission without delivering it, so it can be inspected or held and passed to fireEvent later. |
| fireEvent | Emits a recorded signal emission inside React's act environment, so any resulting state updates are flushed before the promise resolves. |
| formatRole | Converts an accessible role enum value into its lowercase name, falling back to the numeric value when the role is unknown. |
| getAllControllers | Returns every controller of the given type attached to a widget. |
| getConfig | Returns the current global testing configuration. |
| getController | Returns the first controller of the given type attached to a widget. |
| getDefaultNormalizer | Builds the default text normalizer, which optionally trims surrounding whitespace and collapses runs of whitespace into single spaces. |
| getElementError | Builds the error a failing query throws, appending the container's widget tree to the message the way the built-in queries do. |
| getQueriesForElement | Binds the built-in queries, and any custom queries, to a specific container so they search only within that scope. Also exported as getQueriesForElement, which reads better in library code. |
| getRoles | Groups every mapped widget in a container's tree by its accessible role name. Widgets that are not mapped are left out. |
| getSuggestedQuery | Computes the recommended query for reaching the given widget, preferring role, then label text, placeholder text, text, display value, and name. |
| getWidgetText | Returns a widget's own text by trying its label, text, and title getters in order, then the contents it exposes through Gtk.AccessibleText, or null when none produce a value. |
| isInaccessible | Returns whether a widget is excluded from the accessibility tree, because it or one of its ancestors is marked hidden. |
| logRoles | Prints the accessible roles in a container's tree to the console using prettyRoles. |
| logWidget | Prints one or more widget trees to the console using prettyWidget. |
| prettyRoles | Formats the accessible roles in a container's tree as a readable string, listing each role together with its widgets and their accessible names. Widgets that are not mapped are left out. |
| prettyWidget | Renders a widget tree as an indented, HTML-like string showing each widget's tag, accessible attributes, and text content. |
| queryAllByDisplayValue | Finds every widget whose current display value matches. Widgets that are not mapped are never matched. |
| queryAllByLabelText | Finds every widget associated with a label whose text matches: a Gtk.Label mnemonic target, the widget's own accessible label, or its labelled-by relation. Widgets that are not mapped are never matched. |
| queryAllByName | Finds every widget whose widget name matches. Widgets that are not mapped are never matched. |
| queryAllByObjectProperty | Finds every widget carrying a GObject property whose value matches, the counterpart of DOM Testing Library's queryAllByAttribute. The property name may be given in kebab-case or camelCase, and widgets that are not mapped are never matched. |
| queryAllByPlaceholderText | Finds every widget whose placeholder text matches. Widgets that are not mapped are never matched. |
| queryAllByRole | Finds every widget under the container whose accessible role matches role and that satisfies the given options. Widgets that are not mapped are never matched, and widgets excluded from the accessibility tree are skipped unless options.hidden is set. An Adwaita dialog matches once its content is shown, which libadwaita does a frame after the dialog opens. |
| queryAllByText | Finds every widget whose rendered text content matches. Widgets that are not mapped are never matched. |
| queryAllControllers | Returns every controller of the given type attached to a widget, in the order GTK4 reports them. |
| queryByObjectProperty | Returns the single widget carrying a GObject property whose value matches, or null when none do, the counterpart of DOM Testing Library's queryByAttribute. |
| queryController | Returns the first controller of the given type attached to a widget. |
| registerMatchers | Registers the widget matchers on the global expect, when one is available. Safe to call more than once. |
| render | Renders React into native widgets and returns queries, debug helpers, and lifecycle controls. |
| renderHook | Renders a test component that calls the given hook, exposing its latest return value along with rerender and unmount controls. |
| screenshot | Captures a widget as PNG, retrying until it has a paintable size. Writes to options.path when supplied, creating missing parent directories. |
| waitFor | Repeatedly invokes a callback until it succeeds without throwing or the timeout elapses, retrying on each rejection at a fixed interval. |
| waitForElementToBeRemoved | Waits until the given widget or widgets are detached from the tree. Rejects immediately if the target is already absent when called. |
References
within
Renames and re-exports getQueriesForElement