cargo jflib test
Tests that read like instructions.
A .uis script uses your app the way a person does. It clicks, types, drags, swipes and presses keys, then checks what happened. It runs the real app without a window, on a virtual clock, so every run ends with the same result and the same pixels, on your machine and in CI.
One line, one step.
This script fills in part of the Feature Gallery. Each picture is what the app looked like right after that line. Lines that start with expect are the checks. Click a line to jump there.
- click #700
- type "Ada Lovelace"
- expect #700 text "Ada Lovelace"
- click "Option A"
- expect checkbox:"Option A" unchecked
- click "Blue"
- expect radio:"Blue" checked
- drag 105,446 186,446 12
- expect #140 value 84
- key tab up up
- expect #141 focused
- expect #141 value 14
- theme dark
Why it works so well.
The real app
No mocks and no test build. The script feeds the compiled app the same events the platform would.
Headless
The app draws into memory. No window opens, nothing steals your keyboard, and a server without a desktop runs it too.
Deterministic
Time is a virtual clock in 16 ms frames. Timers and animations follow it, so a run never waits and never flakes.
Readable selectors
Name a widget by its label, by kind and label, by id or by a point. Clear rules decide when a label appears twice.
Clear failures
FAIL line 9: … names the line and what was found instead. The script goes on, and the exit code tells CI.
One language everywhere
The same scripts run on Windows and Linux, and they drive the inspector too.
Everything a person can do.
And a few things a person cannot: a script can drop files from another program, suspend the app, feed it sensor readings or lose the GPU, all without a real device.
rclick listitem:"report.pdf" click "Rename" type "final.pdf\n" drag #20 #31 hold 300 shift wheel 400,300 120 ctrl key ctrl+s
tap "Photos" longpress #44 800 swipe 200,600 200,150 250 pinch 300,300 80 240 pan2 300,300 0 -120 drag 100,100 300,180 pen 20 90
click "Save as…" expect dialog:"Save as" open window any click button:"Cancel" expect window 20 closed shot popups.png desktop
drop 300,200 photo.png notes.txt dragover 300,200 text dragleave drag #12 1200,300 dragout expect files 1 dragout end copy
clip text "Hello" key ctrl+v expect #700 text "Hello" key ctrl+a ctrl+c clip expect text
system suspend system resume system settings theme sensor accel 0 9.81 0 location 52.52 13.40 12 location expect fix
Check what matters, down to the pixel.
Expectations read states, values, texts and rectangles from the same records that screen readers and the inspector see. When pixels matter, a script compares a point, an area or the whole window with an earlier picture, byte for byte.
- States: exists, focused, checked, disabled, selected, open, pressed and more.
- Values, ranges, texts and rectangles in device-independent pixels.
- Theme tokens, the style in use, sounds asked for and warnings printed.
--verify-dirtycompares every partial redraw with a full one, so a missed pixel cannot hide.
expect button:"Send" disabled type "Hi" expect button:"Send" enabled expect #140 value 40..60 expect text:"Saved" exists expect #9 rect * * * 36 expect pixel 12 40 #0067C0 expect token accent_text #FFFFFF shot before.png theme dark theme light expect same before.png # byte for byte
Frame budgets as tests.
bench times real frames while things move: an animation, a drag, a stream of wheel turns. It prints the mean, the median and the worst frame, and with a limit it fails when the median is over budget. Three tries ride out a busy build machine.
JFNetworker's performance test pans, zooms and drags a network of 500 devices and 800 cables at 1920 × 1080 this way.
# 300 frames of a drag, at most 16.6 ms each bench 300 drag #50 900,500 16600 # smooth scrolling wheel 500,400 -360 bench 60 anim 16600
Every animation on this site is a script.
The GIFs and screenshots here were not recorded by hand. A script brings each app into the right state and takes a picture after each step, headless. Run it again after a change, and the pictures update themselves.

Every new app starts with a passing test.
cargo jflib new writes tests/smoke.uis next to your code. cargo jflib test builds the app and runs every script in tests/. A first line #!args passes program arguments, and dump prints the widget tree with ids and positions when you write a new script.
The inspector shows the selector of any widget you point at, ready to paste.
# tests/smoke.uis click "Click me" click "Click me" expect text:"Clicks: 2" exists click "Reset" expect text:"Clicks: 0" exists shot target/smoke.png