Skip to content

API Reference / @gtkx/testing / render

Function: render() ​

render<Q>(element, options?): Promise<RenderResult<Q>>

Defined in: packages/testing/src/render.tsx:223

Renders React into native widgets and returns queries, debug helpers, and lifecycle controls.

Type Parameters ​

Q ​

Q extends QueryMap = Record<never, never>

Parameters ​

element ​

ReactNode

React element to render.

options? ​

RenderOptions<Q>

Container, wrapper, custom queries, and render settings.

Returns ​

Promise<RenderResult<Q>>

Bound queries, debug helpers, and rerender/unmount controls.

Remarks ​

Without a container, creates and presents a harness window, which the tree sees as its parent window. Windows the tree opens over it, such as an Adwaita dialog rendered on its own, are shown again after it, so the topmost one is active as in a running application. Initially focused editables keep their text unselected, with the caret at the end. Carets do not blink, so a focused editable does not keep the display redrawing and GLib idle callbacks still run.

Waits for layout and activation before resolving, so focus and other platform state can be read immediately. A new harness waits for its topmost window's activation; a caller-owned or rendered window waits for application activation, since only presentation can claim it. A container that is not shown requires no activation wait.

Widgets outside all toplevels or inside a hidden window cannot receive pointer or keyboard input. userEvent rejects after actionabilityTimeout; use fireEvent to drive them directly.

Errors an error boundary catches go to onCaughtError and do not fail the test. An error no boundary catches rejects this render, or the next rerender, unmount or cleanup, with that error.

Throws ​

If a shown window is not laid out and activated within windowActivationTimeout, or the tree throws an error no boundary catches.