Skip to content

API Reference / @gtkx/testing / render

Function: render() ​

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

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

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. Its initially focused editable keeps its text unselected, with the caret at the end.

Waits for layout and activation before resolving, so focus and other platform state can be read immediately. A new harness waits for its own 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.

Throws ​

If a shown window is not laid out and activated within windowActivationTimeout.