Skip to content

@gtkx/testing / prettyWidget

Function: prettyWidget()

prettyWidget(container, options?): string

Defined in: pretty-widget.ts:187

Formats a widget tree as a readable string for debugging.

Renders the widget hierarchy in an HTML-like format with accessibility attributes like role, name, and text content.

Parameters

ParameterTypeDescription
containerContainerThe container widget or application to format
optionsPrettyWidgetOptionsFormatting options for length and highlighting

Returns

string

Formatted string representation of the widget tree

Example

tsx
import { prettyWidget } from "@gtkx/testing";

console.log(prettyWidget(application));
// Output:
// <GtkApplicationWindow role="window">
//   <GtkButton role="button">
//     Click me
//   </GtkButton>
// </GtkApplicationWindow>