API Reference / @gtkx/testing / render
Variable: render
constrender: <Q>(element,options?) =>Promise<RenderResult<Q>>
Defined in: packages/testing/dist/render.d.ts:24
Renders a React element into a GTK4 widget tree and returns queries scoped to it along with controls for rerendering and unmounting. When no container is supplied, a harness window is created and presented, and the editable it hands the focus to keeps its text unselected, with its caret at the end. The returned promise settles once the window the tree is shown in has been laid out and activation has arrived, so platform state such as focus is already readable when it resolves. A presented harness window is waited on until it is itself active; a window the caller or the tree owns is waited on until the application holds activation, since only a present can claim it. Rendering into a container that is not shown waits for nothing, and a window that never becomes readable within windowActivationTimeout throws an error naming the condition that failed rather than resolving with unreadable platform state. A tree mounted into a container that sits outside every toplevel, or inside a window that is not visible, is out of reach of a pointer and a keyboard, so every userEvent helper aimed at it rejects after actionabilityTimeout naming that condition, and fireEvent drives it instead.
Type Parameters
Q
Q extends QueryMap = Record<never, never>
Parameters
element
ReactNode
The React element to render.
options?
Optional container, wrapper, custom queries, and other render settings.
Returns
Promise<RenderResult<Q>>
A render result with bound queries, debug helpers, and lifecycle controls.
Throws
When the window the tree is shown in is not laid out and activated in time.