---
title: "Recipe: properties beside the tests"
description: "In app.test.contract, state what should hold across the app's interactions."
modificationDate: "2026-11-22"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: properties beside the tests

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/properties: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

In `app.test.contract`, state what should hold across the app's interactions:

```prompt Add properties to my tests
Add properties to the Exact app in this folder: rules in app.test.contract that must hold across every interaction. Use https://github.com/expo/exact/blob/main/docs/recipes/properties.md as the source for each step. The Exact checkout has the same page at docs/recipes/properties.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Read app.contract and list the rules the app means: the values a state may take, what an action writes and what it leaves alone, what never changes once true, and which actions must never be refused. Show me the list and ask before you write them.
3. A property names root states or derives only: no fields, indices or expressions. A derive it names must depend only on state and pure functions, never on a resource, a mutation's status, the clock or geometry. If a rule needs data from app.ts, it cannot be a property: tell me, and leave it to a test.
4. Write the rules in app.test.contract with the recipe's blocks: `always`, `after "<action>"`, `never refuses`, and `only writes` or `writes none`. Change no existing test and nothing in app.contract.
5. Run `bun exact.mjs contract verify app.contract`, then the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json. Read the reports, including counted findings; a zero exit code alone does not mean clean. A property that is false is a bug in the app or a wrong rule: show me the steps that broke it and ask which one before you change anything. Do not weaken a property to make it pass.
6. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 7) and report it; do not keep trying.
7. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
8. Tell me each property and its result (holds, false, counted only or unexercised), the rules you could not write as properties and why, and what verify reported. Keep the `contract verify` receipt unchanged in the app's diary.
```

```contract-test
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 "rotate" "rotating touches nothing but the turns"
  only writes turns

after "done" "done writes nothing and focuses the button"
  writes none
  command focus "done"

never refuses "reset"
```

Read root states or derives by name. Use `Component.action` for a child action.
Derives may read state, pure functions and, in `always`, resources. A refusal
shows the dependency chain. Once true, `stays true` must hold at each observed
step. `after` checks an input's handler and its landed continuations from the
state it met; `after clock` checks the work due when the input arrived.
Other commits make a line counted only. The [grammar](https://exact.expo.dev/reference/contract-grammar/authored-tests.md)
defines each form.

Run `bun exact.mjs contract verify app.contract`. It delivers test prefixes, explores
controls and searches 20 walks of up to 40 chosen events, plus automatic clock
advances. Set `--walks`, `--steps` and
`--walk-seed` to reproduce another search; `--confirm` sets how many walks Lean
confirms, alongside delivered tests, explore and shrunk findings. Without `lake`,
or with `--runner-only`, the runner still searches. `--js` also runs the scripts
on the web JS target and checks `always` there.

The receipt gives the command, source digests, delivery, steps, stores, action
coverage, property results, refusals, timings and evaluators. Properties may hold,
be false, be counted only or remain unexercised. Suggestions are observed and
code-consistent, not proved: the static walk widens frames, drops unsupported claims
and counts both in the receipt. Suggestions never edit tests. Keep the receipt
unchanged in your diary; its digests identify the sources.

“In the semantics' world” means seeded source answers arrive synchronously and
never fail. Scripts can tap, type, land continuations, advance the clock and change
a source’s answer. Reloads, late answers and host inputs are outside that world. A property
about a mutation result is therefore about the seeded answer, and a successful
search establishes only what those scripts observed.

`bun exact.mjs test web` (or `test ios`) checks `always` at boot, after inputs and
reloads, and after every clock step.
`verify` runs both checks; either failure fails it. Its verdict gives counts and
the report and receipt's path, `.exact/verify/properties.txt`. Device and
headless JS runs count unchecked `after`, frame, command and `never refuses` lines:
neither exposes the commit trace they need.
