Visual regression testing framework for Kryon applications.
Kryon-Test provides automated screenshot-based testing for Kryon apps. After making changes to the Kryon framework, you can run tests to verify existing apps still render correctly.
- YAML-based configuration - Define tests in simple YAML files
- Screenshot comparison - Pixel-accurate visual regression testing
- Wireframe mode - Test reactive components (ForEach, state containers) without exact pixel matching
- CLI interface - For CI/CD automation
- Visual GUI - Raylib-based test runner for interactive verification
cd kryon-test
nix-shellThis provides all dependencies including:
- Raylib (GUI)
- libyaml (config parsing)
- stb_image (image loading/saving)
- SDL3 (for running Kryon apps)
Install dependencies:
gccorclangrayliblibyamlpkg-config
cd kryon-test
makeThis builds two binaries:
build/kryon-test-gui- Visual test runnerbuild/kryon-test- Command-line interface
Create a YAML file for your app (see configs/habits.yaml for example):
test_name: "My App Tests"
app:
path: "/path/to/your/app"
entry: "main.lua"
frontend: "lua"
renderer: "sdl3"
window:
width: 800
height: 600
tests:
- name: "main_view"
description: "Main screen"
screenshot_delay_ms: 500
capture_mode: "normal"
baseline: "baselines/myapp/main_view.png"First, create baseline screenshots:
./build/kryon-test baseline configs/myapp.yamlRun tests to compare against baselines:
./build/kryon-test run configs/myapp.yamlUse the GUI for visual comparison:
./build/kryon-test-gui configs/myapp.yamltest_name: "Test Suite Name" # Required
app:
path: "/absolute/path/to/app" # Required
entry: "main.lua" # Required
frontend: "lua" # Optional: lua, nim, ts
renderer: "sdl3" # Optional: sdl3, terminal
window:
width: 800 # Window width for screenshot
height: 600 # Window height for screenshot
tests:
- name: "test_name" # Required
description: "Test description" # Optional
screenshot_delay_ms: 500 # Delay before capture (ms)
capture_mode: "normal" # normal or wireframe
baseline: "baselines/..." # Path to baseline image
wireframe:
show_for_each: true # Highlight ForEach containers
show_reactive: true # Highlight reactive state
color: "#FF0000" # Wireframe color
output:
actual_dir: "output/actual" # Where to save actual screenshots
diff_dir: "output/diff" # Where to save diff images
failure_threshold: 0.01 # Max allowed pixel difference (0-1)- normal - Full pixel-perfect comparison
- wireframe - Shows reactive component boundaries (for testing structure)
Wireframe mode renders a visual outline of reactive components instead of full rendering. This is useful for:
- Testing dynamic content (e.g., calendar dates that change)
- Verifying component structure without pixel-perfect matching
- Testing reactive state containers
Wireframe rendering is controlled by the Kryon framework's test mode:
KRYON_WIREFRAME=1- Enable wireframe renderingKRYON_WIREFRAME_COLOR=#RRGGBB- Set wireframe color
Run all tests in the config file.
./build/kryon-test run configs/habits.yamlExit codes:
0- All tests passed1- One or more tests failed
Generate baseline screenshots for tests that don't have one.
./build/kryon-test baseline configs/habits.yamlValidate the configuration file without running tests.
./build/kryon-test validate configs/habits.yamlList all available test configurations.
./build/kryon-test listLaunch the visual test runner:
./build/kryon-test-gui [config.yaml]Controls:
- Click a test to run it
- View side-by-side comparison (baseline vs actual)
- Click "Accept" to save the actual screenshot as the new baseline
- Click "Save" to save the actual screenshot to the output directory
After running tests, you'll find:
output/<app>/actual/- Captured screenshotsoutput/<app>/diff/- Difference images (red = differing pixels)
Kryon-Test uses Kryon's built-in screenshot capabilities:
KRYON_SCREENSHOT=<path>- Save screenshot to pathKRYON_SCREENSHOT_AFTER_FRAMES=N- Capture after N framesKRYON_HEADLESS=1- Exit after screenshot (for automation)
The configs/habits.yaml file demonstrates testing the Habits Tracker app:
# Generate baselines first
./build/kryon-test baseline configs/habits.yaml
# Run tests
./build/kryon-test run configs/habits.yaml- Check the app path is correct
- Verify
kryonis in your PATH - Ensure the Kryon app runs without errors
- Use absolute paths in config files
- Check YAML syntax is valid
- Baseline was captured at different resolution
- Delete baseline and regenerate:
./build/kryon-test baseline <config>
Same license as Kryon.
This is part of the Kryon project. Contributions welcome!