This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Authored tests
ebnf
test-file = { launch | test | property } ; (* a top-level launch line: every test's *)
test = "test" STRING [ "on" HOST { "," HOST } ] block( { launch } { step } ) ;
HOST = "web" | "macos" | "ios" | "tvos" | "linux" | "windows" | "android" ;
launch = "size" NUMBER "x" NUMBER NL (* written 1200x800 *)
| "epoch" ( STRING | NUMBER | "now" ) NL (* "2026-09-21T12:00:00Z", Unix ms, or now *)
| "time-zone" STRING NL (* an IANA zone, "America/New_York" *)
| "at" STRING NL (* the location it opens at, "/item/7#moves" *)
| "locale" STRING NL (* a BCP 47 tag, "fr-FR" *)
| "seed" NUMBER NL (* 0 through 2^32 - 1 *)
| "stored" IDENT json NL (* initial JSON for a persisted state in this test *)
| "fresh" [ STRING ] NL (* the Snapback dev server emptied first, seeded from the file *)
| "before" "data" NL (* the first step does not wait for data *)
| "prefer" IDENT { "." IDENT } ( IDENT | STRING ) NL
(* media feature, page fact, or permission.<module>; before observations *)
| extension-preference NL (* available at boot *)
| "answer" "source" IDENT "with" json NL (* what a source answers under verify *)
| "fail" "fetch" STRING [ "times" NUMBER ] NL ; (* armed before the first data load *)
extension-preference = "prefer" "extension" extension-key "=" ( json | "clear" ) ;
extension-key = ? a drive key of the form extension.name or extension.name#import-path ? ;
step = "tap" "midi" STRING ( HEX { HEX } | "clock" NUMBER NUMBER ) NL
(* bytes into an input; or clock ticks: bpm, ms *)
| "tap" STRING ( IDENT | STRING ) NL (* when target starts with `@`: answer a held ticket by capability or target, e.g. `tap "@browser" dismissed` *)
| "tap" STRING [ "hover" | "dblclick" | "contextmenu"
| "pinch" NUMBER [ "at" NUMBER NUMBER ]
| "wheel" [ "-" ] NUMBER [ "-" ] NUMBER
| "history" [ "-" ] NUMBER
| "into" STRING
| "modifiers" STRING | "mediasession" STRING [ NUMBER ] ] NL
| "tap" STRING "drag" ( "to" STRING [ "at" NUMBER NUMBER ]
| [ "-" ] NUMBER [ "-" ] NUMBER )
{ ( "press" | "over" | "hold" ) NUMBER | "modifiers" STRING
| "from" NUMBER NUMBER | "mouse" | "into" "keyboard" | "during" STRING { STRING } }
{ "then" [ "-" ] NUMBER [ "-" ] NUMBER
{ ( "over" | "hold" ) NUMBER | "during" STRING { STRING } } } NL
| "type" STRING STRING NL (* when target starts with `@`: type text into a held ticket, e.g. `type "@date" "2026-10-10"` *)
| "type" STRING ( STRING [ "append" ]
| "key" STRING [ "down" | "up" | "for" NUMBER ]
| "copy" | "cut" | "paste" STRING ) NL
| "pick" STRING ( STRING { STRING } | "cancel" ) NL
| "authorize" [ "cancel" ] NL (* the held sign-in, against the app's server (oauth recipe) *)
| "presence" ( "allow" | "cancel" | "fail" | "lockout" | "invalidated" ) NL
(* answer the pending user-presence prompt, as tap @presence *)
| "rotate" ( "portrait" | "portraitUpsideDown" | "landscapeLeft" | "landscapeRight" ) NL
| "fold" NUMBER NL (* hinge angle from 0 through 180 degrees on an iOS simulator with a hinge *)
| "background" NUMBER NL (* whole milliseconds on iOS *)
| "session" ( IDENT | STRING ) NL
(* the later steps go to that window: main, a link's target, window-<n> *)
| "clock" ( "settle" | "data" | "+" NUMBER [ "real" ] | NUMBER ) NL
| "clock" "held" { IDENT } [ NUMBER ( "s" | "ms" ) ] NL
(* real time, the clock frozen, until held requests reply *)
| "clock" "until" "state" IDENT { "." ( IDENT | NUMBER ) } "==" scalar "within" NUMBER NL
(* real time, the clock frozen, until it holds *)
| "resize" NUMBER "x" NUMBER NL (* the window, mid-test: 800x600 *)
| "prefer" IDENT { "." IDENT } ( IDENT | STRING ) NL
(* change a media preference, page fact or module permission now *)
| extension-preference NL (* subsequent calls see the value *)
| "prefer" midi-fact { midi-fact } NL (* each fact at most once *)
| "reload" NL
| "fail" "fetch" STRING [ "times" NUMBER ] NL (* later fetches whose URL starts with it fail *)
| "pass" "fetch" STRING NL (* it stops failing *)
| "answer" "source" IDENT "with" json NL (* the source answers anew; its readers ask again *)
| "drop" "stream" STRING NL (* ends open streams whose URL starts with it *)
| "prefer" IDENT STRING NL (* quoted media preference or root-font-size *)
| "request" METHOD STRING [ json ] [ "as" ( IDENT | STRING ) ] [ "expect" NUMBER ] NL
(* the driver writes through the app's server *)
| "close" NL (* the window's close button *)
| "back" NL (* the platform's Back *)
| "screenshot" STRING NL
| "perf" NL block( step { step } ) (* counts its steps' work; no launch line, `clock … real` or `perf` in it *)
| "expect" "perf" ( "query" IDENT | ( "built" | "evaluated" ) STRING ) ( "==" | "<=" ) NUMBER NL
(* a count of the last `perf` block *)
| "expect" "no" "failures" NL (* nothing failed that the test did not arrange *)
| "expect" "tree" ( "has" | "missing" ) STRING NL
| "expect" ( "disabled" | "enabled" ) STRING NL (* a control's `disabled` (LLP 1116.010 D3) *)
| "expect" "focused" STRING NL (* the node that holds the keyboard focus *)
| "expect" "sample" STRING "at" NUMBER NUMBER "==" STRING [ "within" NUMBER ] NL
| "expect" "screenshot" STRING "matches" STRING NL
| "expect" "layout" STRING measure ( "==" | "<=" | ">=" ) ( [ "-" ] NUMBER | "layout" STRING measure ) [ "within" NUMBER ] NL
(* the border box, in viewport points *)
| "expect" "refusal" STRING NL (* one observed refusal of the named mutation slot *)
| "expect" "text" STRING "==" STRING NL
| "expect" "state" state-path
( ( "==" | "!=" ) ( state-literal | "state" state-path )
| ( ">=" | "<=" ) ( [ "-" ] NUMBER | "state" state-path )
| "in" ( state-literal { state-literal } | "state" state-path ) ) NL
| "expect" "sound" ( "has" | "missing" ) STRING
[ "at" NUMBER ] [ "gain" NUMBER ] [ "ends" NUMBER ]
[ "playbackRate" NUMBER ] [ "pan" [ "-" ] NUMBER ] [ "by" IDENT ] NL
| "expect" "wakelock" ( "held" | "released" ) NL
| "expect" "drag" STRING ( "none" | "has" STRING [ "==" STRING ] [ "name" STRING ] | "missing" STRING ) NL
(* what the node's drag carries, as `tree` shows it (LLP 1094.000) *)
| "expect" "midi" ( "sent" | "missing" ) STRING HEX { HEX } [ "at" NUMBER ] NL
| "expect" "mediasession" ( IDENT "==" ( STRING | "none" )
| ( "has" | "missing" ) STRING ) NL ;
measure = "width" | "height" | "x" | "y" | "left" | "right" | "top" | "bottom" | "centerX" | "centerY" | "baseline" ;
midi-fact = "midi.state" ( "prompt" | "granted" | "denied" | "unavailable" )
| ( "midi.inputs" | "midi.outputs" ) STRING ; (* names, comma-separated *)
HEX = HEXDIGIT HEXDIGIT ; (* one byte, as in 90 3c 64 *)
state-path = IDENT { "." ( IDENT | NUMBER ) } ; (* indexes are whole numbers from 0 *)
state-literal = [ "-" ] NUMBER | STRING | "true" | "false" | "none"
| "some" "(" state-literal ")"
| "[" [ state-literal { "," state-literal } [ "," ] ] "]"
| IDENT "(" [ IDENT "=" state-literal { "," IDENT "=" state-literal } [ "," ] ] ")" ;
test-value = [ "-" ] NUMBER | STRING | "true" | "false" | "none" | "[" "]" ;
scalar = [ "-" ] NUMBER | STRING | "true" | "false" | "null" ;
METHOD = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" ;
json = "{" [ STRING ":" json { "," STRING ":" json } ] "}" (* strict JSON: quoted keys, no *)
| "[" [ json { "," json } ] "]" (* trailing comma; brackets may *)
| STRING | [ "-" ] NUMBER | "true" | "false" | "null" ; (* span lines *)
on web runs a test on the hosts it names and skips it on the others, saying so (LLP 1146 D7):
a test of something only one host has, such as the browser's history after a reload.
perf runs its indented steps and counts the work they did (LLP 1146 D3), for the expect perf lines after it. query channelList is how often the resource's data source was asked;
built "MemberList" the views created and virtual rows constructed at that component's plan
sites (a component the plan declares and never built counts 0), else under the view with that
testId; evaluated the bindings evaluated there. The counts repeat when the steps and the
answers are the test's, on the agent's clock, so clock … real is refused in a block and the
block in a run under platform timing. query and built read the same on every host;
evaluated is each runtime's own, so a test that compares it names one host. The development
source map names components; a host without one says so. A drive's perf <target> during "…"
shows the same counts while a test is being written.
tap "@<target>" <choice> and type "@<target>" "<text>" wait as clock data does,
with the virtual clock frozen, then answer the held device or package ticket named by
capability or target (for example tap "@browser" dismissed or type "@date" "2026-10-10").
Numeric ticket ids ("@1") are refused in authored tests because ticket numbers vary across
runs. For a package choose ticket declared by the app, the compiler checks the choice
against the package's declared choices (plus cancel) and refuses typed text when the
ticket takes choices only. For file pickers, use pick so paths resolve from the test file.
Run clock data after the answer before checking the resulting state.
presence <answer> waits as clock data does, with the virtual clock frozen, then
answers the pending user-presence prompt through the driver's tap @presence.
It fails if no prompt is pending, several match, or the data wait expires.
It answers both a presence secret's unlock and @exact/local-auth's authenticate;
invalidated applies only to unlock. Use prefer permission.local-auth granted
to handle the separate permission prompt, and clock data after the answer before
checking its result. Scope tests with on to hosts that support the operation.
expect no failures fails when, since the test launched or its last expect no failures, a
resource was refused while no fail fetch fired, a send failed that no expect refusal names,
or the runner said a resource was asked again and again (LLP 1146 D4). Without it, a test
still prints those as unarranged: notes, and verify counts them as findings.
Properties live beside the scripts in a test file; a file declaring a component
cannot declare a property. They compile to nothing an app runs. contract verify
checks them against each script's observations on the runner and Lean.
text
always "the phone is on one of its five screens"
expect state screen in "lock" "home" "settings" "display" "messages"
always "the counter is a whole number of at least one"
expect state counter whole
expect state counter >= 1
always "a probe's result is absent or an answer"
expect state tsResult in none some
always "once the photo has loaded it stays loaded"
expect state ready stays true
after "increment" "increment adds one"
expect state counter == old + 1
after "reset" "reset puts the turns back and counts itself"
expect state turns == 0
expect state resets == old + 1
after "rotate" "rotating touches nothing but the turns"
only writes turns
after "done" "done writes nothing and focuses the button"
writes none
command focus "done"
after clock "the probe never touches what the user set"
only writes tsResult rustResult rustExecutorResult
never refuses "reset"
ebnf
property = "always" STRING block( { hold } )
| "after" ( STRING | "clock" ) STRING block( { hold | frame } )
| "never" "refuses" STRING NL ;
hold = "expect" "state" IDENT ( "==" ( test-value | "old" [ ( "+" | "-" ) NUMBER ] | "not" "old" )
| "in" { test-value | "none" | "some" }
| ( ">=" | "<=" ) [ "-" ] NUMBER
| "whole"
| "stays" test-value ) NL ;
frame = "only" "writes" { IDENT } NL (* no other root slot changes *)
| "writes" "none" NL
| "command" IDENT { test-value } NL ; (* the commit issued this host command *)
old is admitted only in after, stays only in always, and frame lines only in
after. The braces in the EBNF mean repetition, not written braces. A read names a
whole root state or derive by its bare identifier; fields and indices are stage 2.
Before any script runs, verify rejects a derive whose body, dependencies or called
functions reach a mutation status, clock or geometry read, or, outside always, a
resource. An always line checks each printed configuration, where the runner and
Lean print the same oracle answer; an after pair could see a resource change on a
step that commits nothing. A mutation's result slot is a state and may be named.
always checks every printed configuration, including boot. stays v means that a
previous observation equal to v must remain v. The work due when an input
arrives (a change action, a timer due exactly then, an armed then or queued send)
runs before its handler; when it runs any commit, it is observed as a due step of
its own, before the input. after "action" reads the value before an input and after
its following land, so old is the configuration the handler met; the input must
have only that successful handler commit, and its landing only then and queue
commits. Other commits, including a commit omitted from the trace, make the pair
counted only. after clock checks clock advances, due steps and landings not
paired with inputs, over all their commits. only writes compares every root slot, including queue results.
never refuses reads the action on each commit line; an action never run is
reported as not exercised. Poisoned configurations are counted, not checked.
Numbers use binary64 arithmetic and IEEE comparisons; other values compare by
their whole printed text. These checks cover observed steps, not every commit
inside a step, and are not proofs.
after and never refuses accept a root action name or a qualified name such
as "Palette.typed". A qualified name covers every instance of that component.
Both contract test and contract verify check the name before running scripts.
If only a child declares a bare name, the diagnostic gives its qualified form.
If a component has no action with the given name, the diagnostic lists its
actions. An unknown bare name stays unexercised. Verification receipts use the
spelling in the test file. Suggested properties use the same component names.
contract test <file> emits an object with tests and properties arrays. Each
property carries kind, name, its declaration line and parsed lines; each
line has its source line and an op (expect-state, only-writes, command).
Values carry a kind and, for numbers, strings and bools, a value. The device
runner currently reads the scripts; property checking on a device is a later lane.
expect refusal "saved" names a mutation slot, after clock data or clock settle
lands its send. It asserts one observed refusal since the previous such assertion for
that slot. Verify accepts that observed failure; other refusals remain findings. A refused
send keeps the slot's prior value and skips its then; assert the rendered failure code
or message as well.
Targets are driver test ids. expect disabled "send" (enabled) reads the control's
disabled, which every host's tree carries (LLP 1116.010 D3). A tap on a disabled control
does nothing, and fails its step on every host, send is disabled: say what the app refuses
with expect disabled, then expect enabled once what enables it has happened. expect focused "picker" passes when that node holds the keyboard focus, as every host's tree marks it
([focused] in agent <host> tree): after a key moves the focus, or a dialog returns it.
expect sample "badge" at 4 5 == "#1280e0" within 2 reads a painted pixel
four points from the left and five from the top of the badge. Colors are
sRGB #rrggbb (opaque) or #rrggbbaa. The optional tolerance is the
largest allowed difference in each 8-bit channel, from 0 through 255.
On Apple this includes the last frame of a GPU canvas and hosted iframe
snapshots, clipped and blended with the views around them: an unpartitioned
iframe reads the node behind its transparent pixels. If the point depends on a live camera preview,
a video frame the player withholds or a hosted layer without a readable
picture, the assertion names the node and the reason.
expect screenshot "badge" matches "refs/badge.png" compares the visible
border box with a PNG relative to the test file. The full box must be in
the viewport. It uses the driver's screenshot comparison on a one-point
grid, with the same tolerance for anti-aliasing. A mismatch reports the
first differing point relative to the box.
expect layout "status-mark" height <= 24 bounds a node's laid-out width or height with
==, <= or >=. The size is that of the box agent <host> layout <target> prints as space viewport: points (CSS pixels on the web) at two decimals, with a presentation transform folded
in (LLP 1012). A failure names the size and the box, so an image a column stretched to its own
width fails its test: height of "status-mark" is 310, expected <= 24 (its box is 420×310).
A size that comes from text, a platform control or the window differs by host: bound it, and
keep == for a size the app sets.
The same step reads x or left, y or top, right, bottom, centerX, and
centerY in viewport coordinates. Compare two boxes with
expect layout "icon" centerY == layout "label" centerY within 0.5. The
optional tolerance is in points and defaults to zero. On graphical hosts, baseline
reads the first rendered text baseline in viewport points. A box without a reported
text baseline fails the assertion.
display="none" keeps a node in the test tree. Assert a hidden pane with
expect layout "list-pane" width == 0 and a shown one with a positive width;
expect tree missing "list-pane" asserts that the node was removed.
size leads a test's steps, as the launch lines below do. A file that does not
parse runs no tests; read file-level errors as well as pass/fail totals. Give each initial
width its own test. To check that a draft survives a width change in one session,
use resize and scope the test to hosts that can perform it:
contract-test
test "a draft survives a window resize" on web, macos, linux
size 1000x700
type "draft" "Eggs"
resize 390x844
expect text "draft" == "Eggs"
session settings sends the later steps to another window of the app, by its name:
main, a link's target, or window-<n> for a window with no name, which is quoted
(session "window-2"). A test starts in the app's first window, main. Each window has its own clock and journal, so clock settle settles the window
the test is in, and expect no failures reads every window the test visited. The Mac
routes by name, as the sample hosts route by their sessions' labels. A host with one
window takes only main, the web driver reads one tab and refuses the step, and a perf
block measures one window, so session goes before it. A label no window has fails the
step, naming the windows there are.
The drivers that perform resize are web, macOS and Linux; iOS refuses a
mid-test resize. Initial size sets the launch viewport. Live iPad window resizing
requires resizing the running window. Use rotate landscapeLeft on an iOS simulator. It waits for
the app's scene to report that interface orientation in layout at screen.orientation.
On a Duo the driver turns the hinge helper's simulated device. Other simulators use
CoreDevice, or XCTest when CoreDevice is unavailable. If a lock keeps the scene in
portrait, the step fails and names the observed device and scene orientations.
The driver logs up to two reissues after a fold. On the iOS 27.1 Duo, one of
100 turns immediately after closing still missed and all 100 after reopening succeeded.
The Android APK runs at the device's size and skips tests with size. Its
--headless mode accepts an initial size.
To assert that a route stays locked through a turn, use a scripted drive. Catch
the rejection from session.rotate("landscapeLeft"), check that its message
reports device turned landscapeRight, scene stayed portrait on an ordinary
iPhone, then check (await session.layout()).screen.orientation === "portrait".
Each test is a session of its own, opened with its
launch lines: size 1200x800, epoch "2026-09-21T12:00:00Z", time-zone "America/New_York", locale "fr-FR" and seed 7 are the driver's --size,
--epoch, --time-zone, --locale and --seed, so they lead the test's steps,
each once; at "/item/7#moves" opens the app at that location, fragment included,
as --url with a path does. prefer platform <name> is also launch-only: it
accepts one of exactPage().platform's ten values (android, ios, linux,
macos, terminal, tvos, web, windows, watchos, headless), survives
reload, overrides exactPage().platform and formatShortcut()'s keyboard
notation (keeping the reader's keyboard for web) in both host drives and
contract verify, and leaves layout, chrome, controls, grants and real key
dispatch on the running host; a branch that mounts a native view or hatch the
running host lacks fails at the prefer platform line. Written at the top of the file they apply to every test that does not
name its own; either way they override the drive's flags. Media preferences
(prefer prefers-color-scheme dark), text size (prefer root-font-size "24") and
a module's permission (prefer permission.notifications granted, denied or
prompt) also lead a test or the file, and may change between steps. Other
single-value page facts, such as prefer online false, use the drive's parser
and aliases; quote numeric values. On the Chromium web host, prefer safe-area "47 0 34 0"
sets the top, right, bottom and left safe-area insets in whole CSS pixels. The
browser applies them to CSS env() values. Native hosts use the device's insets. Folds (posture, segments, gap) and mode
pins require a drive. Defaults
merge by resolved fact name, so aliases override each other; duplicate leading
lines for one fact are errors. A bad name or value fails that test at its line.
A package substitute uses the drive's key <extension>.<name>[#<import-path>].
Both parts take ASCII letters, digits and underscores. The extension can also
contain hyphens. For example,
prefer extension store.outcome="cancel". The compiler checks the package,
the substitute name and each JSON value where it is written, including file
defaults that a test overrides. A record supplies its required fields unless
the declaration fills them or accepts a partial value. Omit each status field
that the package assigns to a permission on the test's host. The host supplies
its declared status on an unavailable target. Otherwise it supplies the
permission state, which a test can set with
prefer permission.<name> granted|denied|prompt.
prefer extension store.outcome=clear
restores the package default. A leading line supplies the value before the
app's first call. A later line changes subsequent calls. A package that reads
its value once at startup sees a mid-test change on the next launch.
Each test and each replay starts from package defaults and runs its lines in
order. A reload or verify relaunch receives the current substitutes together,
including a tag list and the tag in the field.
The latest values survive reload and verify's relaunch. A file whose
assertions depend on the date says so in the file. epoch now is the machine's
clock, read once as each test launches, for a test whose app talks to a live
backend on real time (snapback4 dev); its dates differ run to run, so its
expects do not name them. fresh empties each snapback4 dev server the app
fetches (a loopback net.fetch grant) before the test opens, through the
server's development door POST /dev/reset; fresh "seed.json" then seeds it
with that file's [{"table": …, "row": {…}}] (a path from the test file). At
the top of the file it runs before every test. A server without the door (a
snapback4 older than the release that adds it answers 404) fails the test,
saying so. Before the first step, and
after a reload, the driver waits for the app's data as clock data does (its
module activated, every request in flight answered and each answer's then
landed, the clock unmoved); before data skips the wait. fail fetch "<prefix>"
(LLP 1103) makes every later fetch whose URL starts with the prefix fail as a
refused connection does, on every host: a TypeScript source's fetch rejects
with FetchError of kind "Network", a Rust source's request settles
Failed { kind: Network }, and the request never goes out. times N (a
positive whole number) fails only the next N; pass fetch "<prefix>" stops it.
Leading the steps, or at the top of the file, fail fetch is a launch line,
armed before the app's first data load; later it is a step. Several prefixes may
be armed; the longest matching prefix decides, and arming a prefix again
replaces it. A file's line applies to every test that does not arm the same
prefix itself. A counted fault that matched no fetch by the test's end (or
before it is armed again) fails the test at the line that armed it, and
reload relaunches with the table as it is then. Each HTTP attempt of a long
poll (exactStream with exactLongPoll) takes a matching fault and retries as
a network failure. Event streams, byte streams and WebSockets use
drop stream "<prefix>". This step ends every open matching stream and
releases its connection. The mapper receives a terminal error of kind
"Network" (Rust receives Failed { kind: Network }). Frames waiting behind
an unfinished mapper are discarded. If no open stream matches, the step
fails at its line. Wait for a value that confirms the stream is open before
dropping it. Long polls use fail fetch on their individual HTTP attempts
because their transport repeats buffered requests. Upload progress streams
and local listeners are outside this step's scope. The web's wasm host
opens event streams and WebSockets. It reads byte streams as buffered replies.
fail source <name> ["<message>"] [times N] and pass source <name> fail and
restore an app data source (resource queries, mutations, and direct package
calls) at the runner and web-js source boundary with code: "error" and the
given message (default "source failed (driver fault)"), before invoking
the source owner. Like fail fetch, fail source may lead a test or file
(before the first load) or run mid-test, survives reload, fails at its line if
a counted times N fault matched no call, and is counted as an arranged failure
by expect no failures. Unknown sources and runner-owned sources (exactPage,
exactViewport, exactTime, etc.) are refused at compile time. On a resource
read, the resource keeps its prior settled value, its else placeholder, or the
type's zero value (refusing the commit when a placeholder else source() itself
fails); on a mutation send, the failure is recorded without poisoning the
session. Indirect package calls made inside Rust or TypeScript data code stay on
prefer extension <ext>.<name>={"error": …}. contract verify skips tests
using fail source / pass source (source failure is outside the synchronous
Lean oracle, LLP 1109 D3); run them on host drives.
answer fetch "<prefix>" [method GET] with <status> [header "<name>" "<value>"]… [<body>] [after <ms>]
supplies an HTTP response, with no request to the service. It may lead
a test or the file, like fail fetch, so the first resource load receives it.
An HTTP method limits the answer to those requests. A test can return the old
value for method GET and the saved value for method PUT at the same URL.
A later rule replaces the rule for the same prefix and method. A test's
leading rule overrides the matching rule in the file.
By default the response arrives immediately. With after 200, the request
selects its response when it starts and delivers it 200 milliseconds later on
the test clock. Replacing the rule leaves that response in flight. clock data
can finish a save while its earlier read waits. clock +200 delivers the read.
JSON bodies are sent as application/json; a quoted string is sent as
text/plain; charset=utf-8, and an omitted body is empty. An explicit
content-type header overrides that default. The status is 200 through 599,
excluding redirects 301, 302, 303, 307 and 308. Statuses 204, 205 and 304
require an empty body. A response has at most 1,024 headers and a body of at most
64 KiB; the complete encoded fixture table must also fit 64 KiB, including headers
and URL prefixes. An answer that exceeds a limit is refused before arming. set-cookie and set-cookie2 headers are
refused because browsers hide them. Request validation, grants, file-body
preparation, aborts, deadlines and response-size limits still apply. A refused fixture records no hit
or answered journal line.
The longest matching prefix wins. At the same prefix, an explicit method wins
over a rule that matches any method. fail fetch replaces the rule for any
method. pass fetch clears all rules at that prefix. Long polls ignore answer entries when choosing a failure, so
a longer answer prefix does not hide a shorter failure. Otherwise the request
goes to the network. Each test starts with its own table; reload keeps the
current answers and cleared entries. On the web, only the top-level document on
the original app origin receives the table; child frames and other origins do not.
Development render servers apply the table before fetching request-time data.
A web launch revalidates only matching checkpoint answers through the real source;
unrelated rendered answers stay settled.
The real source parses the response, so an HTTP error status is a response,
where fail fetch is a rejected connection. answer fetch covers buffered HTTP
requests, including a worker's; streams, long polls, redirects, exactBodyTo
and response files are not supported.
answer stream "<prefix>" [method POST] with <status> [header "<name>" "<value>"]…
answers matching HTTP(S) exactStream requests (event streams and byte streams)
without opening the network (LLP 1103). Like answer fetch, it may lead a test
or the file, or run as a step; pass stream "<prefix>" disarms all stream
fixtures at that prefix. Stream fixtures live in their own namespace, so an
answer fetch and an answer stream can share a prefix without colliding.
For a streaming 2xx status (200–299 except 204 and 205), indented lines declare
the schedule, with monotonically non-decreasing cumulative after <ms> offsets
from stream open (default after 0):
•
event <string | JSON> [name "<name>"] [id "<id>"] [after <ms>] delivers an SSE event (content-type: text/event-stream by default).
•
bytes <string | base64 "<b64>"> [after <ms>] delivers a byte chunk (content-type: application/octet-stream by default; cannot mix with event rows).
•
end [after <ms>] ends the stream cleanly (HTTP EOF).
•
fail "<message>" [after <ms>] ends the stream with a network error and counts as an arranged failure for expect no failures.
Without a terminal end or fail, the stream stays open after its last row so
the test can act mid-stream (such as pressing Stop or running drop stream).
after 0 rows and exactStreamOpen land on clock data; later rows and
virtual exactIdleTimeout deadlines do not extend clock settle on their own
(advance virtual time with clock +<ms>, though any clock advance past their
offset—including a clock settle moving for an unrelated animation or data
timer—delivers them). For a non-2xx status (400–599) or 204, 205 or 304,
the inline form answer stream "<prefix>" with <status> [header …] [<body>] [after <ms>]
delivers a terminal buffered HTTP response without exactStreamOpen. Long polls,
WebSockets, upload progress streams, exactBodyFrom and exactBodyTo are
outside answer stream.
answer source pairing with {"phase": "code", "code": "123456"} supplies a typed
answer in contract verify. It applies to every argument list for that source.
An omitted record field keeps its previous value for those arguments, or the
seeded value on the first call. Verify checks the named fields against the
declared result type before running the test. A failed expectation in a test
that supplies a source answer fails verification.
A leading line supplies the answer at boot. A test's leading line replaces the
file's default for that source. After boot the line changes the answer and asks
the source's live readers again in one commit. Lean and --js replay the
changes in order. On a device, agent --test reports tests that require these
oracle answers as skipped.
request POST "/polls/1/votes" {"option": 2} as bob
(LLP 1116.006 D8) is the driver, not the app, writing through the app's server as
another person: a method, a path in quotes under the server URL app.ts calls (its
first local one, http://127.0.0.1:8787; or a whole http:// URL), an optional JSON
body (sent as content-type: application/json), and as <persona>, sent as
Authorization: Bearer <persona> (the rest pattern's tokens are ada and grace;
as "token-grace" for a token that is not one word). A status outside 200 through
299, or no answer, fails the step naming the status and the body's start; expect 409
after the persona (a status from 100 through 599, LLP 1116.010 D3) is the test of a
refusal: that status passes it, any other (a success too) fails it. The app
shows the write when it next reads, so follow it with clock +<its poll's ms> and
clock data before the expect (a failed expect before the clock moved says so).
test, verify and agent --test restart an owned server empty for each test,
including memory-only servers (database: false). Remote servers stay shared.
Only test and agent --test share an ancestor's server, saying so;
verify refuses an answering local server, including an ancestor's.
A dev server already answering at an owned server's address is refused. Runs take the server's port in turn (another checkout's
run on it is waited for, and named). fail fetch does not reach a request: the driver sends
it, not the app. Arguments after the entry in app.json's commands.server are passed
through in order. For a server that keeps no database, set "server": { "database": false }
beside commands to omit DB and skip scratch database creation and removal.
tap "id" drag to "other" [at x y] ends on the other
node (LLP 1094 D12). tap "id" drag dx dy is the driver's tap … drag (from the
node's middle, or from x y in its box, in points; press, over, hold in
milliseconds; each once; modifiers "Shift" held throughout). then dx dy, up to
seven times, moves on from where the drag before it ended, with its own over,
hold and during: tap "stage" drag 100 0 from 50 50 press 500 over 200 then 0 80 over 200 hold 100 presses for half a second, drags right, then down, holds and
lifts (not after drag to). It is a finger where the carrier has one (the web,
iOS: on a simulator the touch runner's real gesture, LLP 1080.000 §11, which a
test with a drag starts for its session; a phone has none yet and fails the
step); mouse makes it the left button on the web, with the page's pointer
fine, so a desktop path is what runs (iOS refuses it; macOS and Linux drag
with the mouse anyway). A finger's drag the browser takes to scroll an
ancestor ends in panrelease and a pan cancelled journal line naming the
touch-action that keeps it. during "op" …: each quoted op is a read
(tree, layout, state, logs, screenshot) or clock, run while the finger
is down, after its leg's move and before its hold. A test file runs these reads
and compares nothing, and refuses an expect there; a drive returns them in its
reply's during list (bun exact.mjs agent macos 'tap knob drag 0 40 mouse hold 300 during "state"'), which is how to inspect what a drag shows while it is held.
The gesture takes its press,
over and hold on the test's clock, so performanceNow() in the app's pointer
actions reads them: a move's samples are a frame apart on the clock, the first
one frame after the press (500 ms of press reads 515 on the web before a 200 ms
move, its first sample's), and the lift reads the whole gesture. iOS's touch is
real, so there the clock follows it on real time, at each phase's start no
earlier than that phase's time (the same press reads 500 to about 501), and the
lift reads the whole gesture exactly; assert a hold as a range, expect state heldMs >= 500 and <= 520. Under --timing platform the platform's own clock
owns the gesture.
tap "id" pinch <scale> [at x y] is the driver's pinch: scale greater than 0,
about the node's middle or about at in its box. A canvas that takes raw input
receives it as a real pinch arrives there: two touch contacts on the web and iOS,
a Control-held wheel on macOS. A zoomable scroll (-exact-max-zoom, LLP
1057.001.000) is left zoomed as the platform's pinch leaves it at rest, its
scrollZoom times scale within its range; the iOS agent's --touch platform
plays it as two real fingers, which UIKit's own recognizer reads. On Android and
Windows it is the pinch the reader's recognizer or the second contact tells the
presenter, in steps about the point; Linux answers it unsupported. The agent's
tap <t> dblclick touch is a finger's double tap rather than a mouse's: on iOS,
the web, Android and Windows it zooms a zoomable scroll where no dblclick
handler takes it (two real taps under --touch platform, two touch points in
Chrome, two touch contacts on Android and Windows), and macOS and Linux answer it
unsupported. The agent's tap <t> fingers <n> [at x y] puts two to five real
fingers down together under iOS --touch platform, level about the node's middle
or at, 50 points apart, and lifts them together, as the window's recognizers
read several fingers (four open the developer menu); without the runner, and on
other hosts, it answers unsupported. On the web, Android, Windows and Linux, tap <t> wheel 0 <dy> modifiers Control is a trackpad's pinch, as the platform delivers one.
tap "id" wheel <dx> <dy> is the driver's wheel (the agent's tap <t> wheel dx dy) at the node's middle, in points (CSS pixels on the web): a positive dy
scrolls on toward the content's end, so its offset grows, and a negative one back
toward its start; a positive dx scrolls right. It lands at once, with no
momentum, so a Mac's scroll can be tested where a drag selects text instead.
tap "root" history <delta> traverses browser history on the navigation root:
a nonzero 32-bit integer, negative for Back and positive for Forward. It uses
the browser's history.go, including entries kept across reload; other hosts
report unsupported. Scope these tests with on web.
tap "zone" drop file "a.pdf" text "Mount Fuji" url "https://example.com/" is
the driver's drop (the agent's tap <t> drop) at the node's middle: a drag
from another app carrying the files, each file once and its path from the
test file's folder, the plain text and the link, at least one of them
(Pointer, drop). It runs where drops do
(the reference's table).
tap "id" dblclick and contextmenu are the driver's forms of the same names
(no Linux carrier double-clicks). tap "list" into "key" brings a virtualized
list's row into view by its key, so a row outside the rendered window can be
tapped by its own id on the next step. For a mounted target, scroll "id"
brings its middle into view through the enclosing scrollers without pressing it.
A plain tap "id" already asks the host to reveal its target before pressing it. type "id" "text" sets the field's
value, as Playwright's fill; append adds the text after the value the tree
shows (a prefilled reply). type "id" key "Name" presses the key (on iOS,
ArrowRight or ArrowLeft at an input type="range" that shows its UISlider
is the slider's accessibility increment or decrement, the call VoiceOver's
swipe makes; its halves are that step's keydown with the move, then its
keyup, and a held key's repeats move it again);
down and up are the two halves, and for <ms> holds it that long on the
virtual clock (down or up together with for is refused). contract verify
delivers a key press to a box or text and its ancestors, including the release.
Tab and keys on controls or elements with press stop verification at that step
(semantics/README.md). reload restarts the app on the store it had: the
web page reloads its current URL in the same profile, keeping Back and Forward
entries; each separate test starts with an isolated history. A native app
relaunches on the same scratch store with a fresh navigation stack. On Linux,
Windows, macOS and iOS, a path or app scheme --url supplies the launch
location. Without one, the host uses its no-link cold launch location: the
manifest's start_url on Apple (/ by default), / on Linux and Windows.
An HTTP(S) --url selects a development
server and does not override that launch location. A leading at changes
only the test's first launch, not the native reload destination. On every
host, state starts over and performanceNow() is 0 again, at the date the test
had reached (epoch plus its clock steps); what the app stored is what it
reads, so persistence is testable.
To test a detail-route launch on Linux, Windows, macOS or iOS, lead the test
with at "/item/7" and assert the detail screen before any reload. To test
reloading at that URL, run
bun exact.mjs agent linux --url /item/7 --test app.test.contract
(or use windows, macos or ios). That opens a fresh stack at /item/7
on each reload; it does not preserve the stack the test built through navigation.
Android's APK reader opens a path or app scheme --url and a leading at
path as its launching intent's data, as a link opens the app. agent android --headless runs the Linux host on Android and accepts both.
close presses the window's close button as ⌘W or the red button does (the
driver's close): its
beforeunload handlers hear it, and a window one keeps stays open, so the
test goes on to the app's own "Save changes?" (on the web the browser's "Leave
site?", answered "Stay"). A window that closes, by close or by a press the app
answers with close(), takes the session with it, and a step after it fails
naming the line. macOS and the web; iOS and Linux close no window and refuse it.
back is the platform's Back, as a person takes it, from what is on top: an
open dialog's cancel (a modal dialog or role="alertdialog" popover: Escape
on the web and macOS, the alert's Cancel on iOS), else the top sheet dismissed
(a navigationPresentation="modal" route: iOS's swipe down), else the pushed
route popped (iOS's Back button, the browser's Back, ⌘[ on macOS, Alt+Left on
Linux). A route goes back as those do: its Back control pressed, else the root's
navigate with the location beneath, else the router's own back. One the app
refuses (a disabled Back control, closedby="none") is a note, and the test
goes on; with nothing to go back from the step fails. It names no target: tap
the app's own control to press it.
type on a select chooses an enabled option by value, else by its one label;
on a date, time or range input it sets the value in HTML's format; on a checkbox
it takes true or false, on a radio true. A target out of view is scrolled into view first.
A plain tap the host refuses as covered is scrolled into view again and pressed once more when that
moved it (an Android keyboard leaving between the two gives the navigation bar its room back, which
can park the target under it); one nothing scrolls clear is refused.
An input step ends with what it settled (an answer given in the input's turn,
and its mutation's then; on a native host, not one given while another
answer's storage is in flight, LLP 1097); otherwise the clock stands still between steps:
what an input starts (a reply on real time, a transition) lands at a clock
step, as clock settle (or clock data, which lands replies and their thens
without moving the clock); a timer fires when the clock reaches or passes its time
(clock +N), and clock settle fires one only if it reaches it while advancing
to a motion's end.
expect text reads the node's text, else a control's value (a select's chosen
value, not its options), else its descendants' text in order (a button's label),
else a field's value. expect state name.field reads a field of a record at any
depth, and name.0 a list index (a whole number from 0); a missing field fails
naming the fields there. The expected value uses the expression grammar's literals:
numbers, including negatives (== -3), strings, bools, none, some(literal),
lists (["a", "b"], [[1, -2], []]), and shapes with literal fields
(Point(x=1, y=-2)). Lists and shapes may span lines and keep a trailing comma.
== and != compare structurally, without type coercion. Numeric bounds use
>= or <=; in checks membership in space-separated literal alternatives.
Every operator also accepts state <path> on the right: expect state pinned == state locked,
expect state offset >= state minimum, or expect state mode in state allowedModes.
Bounds require two numbers; membership requires a list on the right whose element
type matches the left. Incompatible path types fail compilation with both types
named. Both paths read one state reply; a missing path fails even with !=, while
a present none compares as a value. A mismatch prints both values and, for a state
operand, its path. Computed expressions (-1 + 2, [count]) are refused.
expect wakelock held and expect wakelock released compare state.wakelock.held.
This is the runner's holder record: displayed elements requesting the lock, not
whether the OS or browser granted it. A failure names the holding view ids and
their testIds when present, or says nothing holds it.
expect sound has "assets/x.wav"
passes when the runner's record of voices (every host's, under the driver's
clock) holds one of that source matching each clause given: its start (at,
runner milliseconds), its gain, its end (ends), its playbackRate and pan
(a voice that set neither has 1 and 0), and how it ended (by end|group|cut|stop|cancelled); missing is the negation. A dropped call is not
a voice, and a test that asks about a voice the 1,024-voice record no longer
holds fails and says so. MIDI's steps (LLP 1125 §4): prefer midi.state granted midi.outputs "OP-XY, IAC" midi.inputs "keys" sets what a request
finds under the driver (granted unless named) and the ports, by name (a port
named no longer is disconnected); tap midi "keys" 90 3c 64 is one delivery
from that input now, refused unless the input is connected and a mounted
element hears it or a sequence follows it; tap midi "keys" clock 125 2000
sends Timing Clock from that input at that tempo for that long from now, as
an arm does, a delivery every 50 ms with the clock moved to each (a tempo
whose tick is a whole number of milliseconds, such as 125 or 100, keeps
every stamp exact); expect midi sent "OP-XY" 99 4c 7f at 500 passes when the
runner queued that message for that output and has not taken it back (at
that time, when given), missing the negation. Each byte is two hex digits.
tap "audio" mediasession "seekforward" calls the
handler the platform would call for that media session action (LLP
1098 D10): play, pause or one of the
six; its number is a seek's seekOffset (absent: the element's own) and
seekto's time (required there). It is never a press, needs no box, and is
refused when the element does not own the session or does not offer the action.
expect mediasession reads state.mediaSession: owner (by testId, or
none), title, artist, album, artwork (as authored) or playbackState
== a string, or has/missing an offered action. The test compiler emits steps as JSON;
the agent driver executes them. Its interactive API (bun exact.mjs agent --help) is
larger than this test-file grammar.
Is this helpful
Last updated November 30, 2026