Skip to content

Function: mountInk()

@termwright/ink


@termwright/ink / mountInk

mountInk(element, options?): Promise<InkHarness>

Defined in: ink/src/mount.tsx:148

Mounts an Ink element in this process and returns a harness over it.

The component runs against a headless VT emulator fed by Ink’s own output, so everything the driver offers a real terminal applies here: getByRole, viewport cells and press() as key bytes. No callback is ever invoked directly on the component — asserting a prop spy after physical input is the point. Ink currently leaves occlusion unknown, so semantic click is deliberately refused; drive activation with the keyboard.

The mount resolves once the first frame has been published, so locators work immediately.

ReactNode

MountInkOptions = {}

Promise<InkHarness>

const onPress = vi.fn();
const harness = await mountInk(<Approve onPress={onPress} />, { columns: 40, rows: 10 });
await harness.press('Tab');
await harness.waitForQuiet();
await harness.press('Enter');
await harness.waitForText('approved');
await vi.waitFor(() => expect(onPress).toHaveBeenCalledOnce());
await harness.close();