Skip to content

Snapshots and tests

To see a layout at every screen size without resizing windows, render it headlessly into PNGs (phone, tablet, desktop):

Terminal window
odin run example -collection:lib=. -define:KILN_SNAPSHOT=true -define:START_PAGE=2

The files land in snapshots/. No window opens.

definewhat
KILN_SNAPSHOT=truesnapshot build instead of a window
KILN_SNAPSHOT_DIR=...where the PNGs go (default snapshots)
KILN_SNAPSHOT_SIZES=phone,desktopwhich sizes to render (default phone,tablet,desktop)

Config has snapshot hooks:

fieldwhat
snapshot_setuploads test data after init (gets the model as rawptr)
snapshot_openrenders an extra image per dialog / drawer
snapshot_pointerhovers a point (tooltips)
snapshot_clicksclicks before rendering (open popups)

Tasks run synchronously in snapshots, so the images are the same every time.

The demo exposes two of them:

Terminal window
odin run example -collection:lib=. -define:KILN_SNAPSHOT=true -define:START_PAGE=4 -define:SNAPSHOT_OPEN=reset

Tests run headlessly too:

Terminal window
odin test kiln -define:KILN_SNAPSHOT=true