Automation and errors
Drive an app from code on the real native renderer, or without any window through WebAssembly, and catch every recoverable failure in one handler.
TestRenderer
createTestRenderer runs the app on the same native renderer as in production, with locators, pointer and keyboard actions, waits and capture. headless: true keeps the window hidden for CI machines that still have a renderer surface.
import { createTestRenderer } from "@tarve/core";
const test = await createTestRenderer(App, { renderer: "cpu", headless: true });
await test.getByRole("button", { name: "Save" }).click();
await test.getById("project-name").fill("Tarve demo");
await test.waitFor(snapshot => snapshot.nodes.some(node => node.text === "Saved"));
await test.advanceMotion(50); // deterministic motion time from now on
const midpoint = await test.inspect();
await test.capture("dist/saved.png");
test.close();waitForIdle() waits for pending updates and activeMotions === 0. launchTestProcess isolates CPU/GPU runs in child processes; readPngRgba, comparePngCaptures and assertPngMatches are the pixel-regression helpers Tarve's own visual tests use.
Without a window
@tarve/headless runs the same tree, layout, text, input and CPU painter compiled to WebAssembly: no window, GPU or native library. Fonts are bundled and time only moves with advanceMotion, so captures are byte-identical across platforms. For Testing Library–style queries on top of it, use @tarve/test.
import { createHeadlessTestRenderer, matchImageSnapshot, renderToRgba } from "@tarve/headless";
const test = await createHeadlessTestRenderer(App); // the TestRenderer API
await matchImageSnapshot(await renderToRgba(App, { scale: 2 }), "__snapshots__/app.png");Error handling
const app = createApp(App, {
onError(event) {
console.error(event.source, event.event, event.targetId, event.error);
},
});Recoverable failures from callbacks, listeners, hotkeys, the bridge, requests, dialogs and updates arrive here with their source. A failed native update keeps the last confirmed tree. In development mode, render and handler errors also show an in-window overlay (see Project and dev tools).