.claude/skills/rezi-write-tests/SKILL.md
Write tests for Rezi widgets, screens, or app logic using createTestRenderer and node:test.
npx skillsauth add rtlzeromemory/rezi rezi-write-testsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when:
packages/core/src/testing/ — test utilities (createTestRenderer, etc.)packages/core/src/widgets/__tests__/ — existing widget tests (use as examples)packages/core/src/widgets/__tests__/composition.animationHooks.test.ts — animation hook test patternspackages/core/src/app/__tests__/widgetRenderer.transition.test.ts — ui.box transition expectationsscripts/run-tests.mjs — test runnerpackages/core/src/testing/snapshot.ts — golden frame snapshot utilities (captureSnapshot, serializeSnapshot, diffSnapshots)scripts/rezi-snap.mjs — CLI for snapshot capture and verificationCreate test file in the appropriate __tests__/ directory
Use createTestRenderer() for widget/render tests:
import { describe, it } from "node:test";
import * as assert from "node:assert/strict";
import { createTestRenderer, ui } from "@rezi-ui/core";
describe("MyWidget", () => {
it("renders correctly", () => {
const r = createTestRenderer({ viewport: { cols: 80, rows: 24 } });
const result = r.render(ui.text("hello"));
assert.ok(result.findText("hello"));
});
});
Test state logic by testing reducer functions directly:
it("increments count", () => {
const state = reducer({ count: 0 }, { type: "increment" });
assert.strictEqual(state.count, 1);
});
Use result.toText() for snapshot-style assertions
Use result.findById() to locate specific nodes in the render tree
Use golden frame snapshots for visual regression:
import { captureSnapshot, serializeSnapshot, diffSnapshots, parseSnapshot } from "@rezi-ui/core";
const snapshot = captureSnapshot("my-scene", myView(state), { viewport: { cols: 80, rows: 24 }, theme }, "dark");
const text = serializeSnapshot(snapshot);
// Compare with stored snapshot using diffSnapshots()
Run snapshot CLI for bulk capture/verify:
node scripts/rezi-snap.mjs --update # Capture new snapshots
node scripts/rezi-snap.mjs --verify # Verify against stored
For animation features, cover:
position / size / opacity) for ui.box transitionsFor extended routed actions, verify UiEvent payloads for widgets that emit non-press actions:
action: "toggle" with checkedaction: "select" with indexaction: "rowPress" with rowIndexaction: "change"For animation hook behavior, test:
linear, quad, cubic) resolve as expectedloop: true) remain active and deterministic# Full suite
node scripts/run-tests.mjs
# Single file
node --test path/to/test.ts
testing
Write tests for Rezi widgets, screens, or app logic using createTestRenderer and node:test.
development
Add routing with guards and nested outlets to a Rezi app. Use when building multi-page/screen TUI applications.
tools
Profile and optimize Rezi app performance. Use when app feels slow, frames drop, or render phases take too long.
tools
Add modal dialogs and overlay UI with focus trapping. Use when implementing confirmations, alerts, or layered interfaces.