Recipes

Testing your widget

Visual goldens (this repo)

Cases live in tests/cases/*.json, fixtures in tests/fixtures/**, screenshots in tests/golden/{platform}/*.png.

SurfaceCommand
Desktop HTML (Chromium, host OS)pnpm test:desktop / pnpm test:desktop:update
Desktop HTML (Linux Chromium, CI image)pnpm test:desktop:linux / pnpm test:desktop:linux:record
Android unitpnpm test:android
macOS Swiftpnpm test:macos:visual
Geometrypnpm test:geometry
Rust (incl. commands through Tauri's mock runtime)pnpm test:rust or pnpm test:rust:nextest
CLI (init-ios on a fixture project.yml, validate, doctor, …)pnpm test:cli

Playwright baselines per host: macOS → tests/golden/desktop, Linux → tests/golden/linux-chromium (the pinned mcr.microsoft.com/playwright image CI runs), Windows → tests/golden/windows. tests/golden/linux is the WebKitGTK host (just record-linux), a different engine.

With CI set, a case without a baseline fails (locally it is only a note), a test that passes on retry is listed as flaky in the job summary, and out/linux-chromium/*.actual.png / *.diff.png are uploaded as the playwright-diffs artifact.

Contributor deep-dive: Render testing, Visual stand.

In your app

  1. Keep fixture JSON next to the feature that builds WidgetConfig
  2. Use the showcase playground (same desktop renderer) to iterate on layout
  3. On device, prefer { type: "timer" } / date styles for live UI instead of burning WidgetKit reload budget
  4. Call getWidgetDiagnostics(group) when a native surface looks empty — check receipts and skipped capabilities

Docs check

pnpm docs:audit (also run from docs:generate) fails when a schema element or property has no description. Logic is checked by mutation testing, not by coverage counts (Mutation testing).

Windows goldens are recorded on a Windows VM via PreviewHost (just record-windows <case>, full WPF Adaptive Cards renderer).