Adopt Rehearse in a repository
Adopting Rehearse starts with rehearse init, and the first comparison after it finds every scenario new.
$ rehearse initWrote …/shop/rehearse.yaml.Keep the blocks this repository has, then run `rehearse check`.
$ rehearse compare --base main0 as on the base · 8 new
new: The shop says it is up (packages/api/items.hurl:4) The shop names itself (packages/api/items.hurl:8) The legacy ping answers (packages/api/items.hurl:14) The owner sees every item (packages/api/items.hurl:18) A member isn't told the admin page exists (packages/api/items.hurl:25) The count is right (packages/api/items.hurl:30) Nobody is let in without a token (packages/api/items.hurl:37) The weekly stock report lists every item with its price (packages/report/weekly.rehearse.yaml)Stand-ins: payments (fake, for The payment provider).Adopting Rehearse means writing down what the repository has, and what it does today. The first comparison finds every scenario new: the base has never heard of them. Once they are merged, every change after is compared against them.
Start with a manifest
Section titled “Start with a manifest”-
Write a starter manifest. Run
rehearse initin the repository’s root, whererehearse.yamlbelongs.Terminal rehearse initIt writes
rehearse.yamlwith every block, commented.--forcereplaces one that is there. -
Keep the blocks this repository has. Every block is optional. A component library may keep only
scenarios; an API keepsservices,signIn,peopleandworlds. The following manifest keeps the blocks of a small shop: one API, two people and one world.rehearse.yaml base: mainservices:api:up: node packages/api/server.mjs --port {{port}}port: autoready: http://127.0.0.1:{{port}}/healthsignIn: { command: node people.mjs, service: api }people:owner: { describe: Runs the shop, default: true }member: { describe: A customer with an account }worlds:stocked:add: node seed.mjs {{api_url}}default: truescenarios:calls: ['packages/**/*.hurl']files: ['packages/**/*.rehearse.yaml']Services, people, worlds and stand-ins explains each block, and the rehearse.yaml reference lists every field.
-
Check it.
rehearse checknames each mistake with its line.Terminal $ rehearse checkrehearse.yaml:31: The world “emtpy” isn't declared: there is “empty”, “one-org”. -
Bring it up once by hand.
rehearse upbrings the services up and builds the default world;rehearse peoplesays who signed in;rehearse downstops it all. -
Keep Rehearse’s state out of git. Add
.rehearse/to.gitignore. It holds base worktrees, the cache, logs and runs.
Record today’s behaviour
Section titled “Record today’s behaviour”Write scenarios for what works today, beside what they try: a call beside each handler that matters, a story for each component, a flow for each path a person takes, a file scenario for each report. Start with what a reviewer would check by hand.
-
Write a few, then
rehearse run '<id>'each until it passes on the code as it is. -
Compare with the base. Every scenario is new: the base has no such file. New scenarios don’t fail a comparison, so it exits 0.
-
Commit them, with the manifest, and merge. The base has them now. From the next change on, each scenario is compared, and gets a verdict.
Compare against the base today
Section titled “Compare against the base today”A scenario read beside the manifest (a path starting with ./) is the same file on both sides: the base runs the
head’s definition. So today’s behaviour on the base is recorded the day you write it.
scenarios: calls: ['./rehearse/*.hurl'] files: ['./rehearse/*.rehearse.yaml']The first comparison then finds every scenario as on the base.
$ rehearse compare --base main8 as on the base
8 ids, times and opaque values were set aside before comparing.Stand-ins: payments (fake, for The payment provider).The base has no rehearse.yaml and no scenarios, and it doesn’t need any: the head’s manifest drives both sides. Such
scenarios are never new and never edited, so only an announcement says one changed. Move them
beside the code later, when you want each side to run its own.
Keep the manifest outside the product
Section titled “Keep the manifest outside the product”Sometimes the manifest can’t live in the product yet: you are trying Rehearse before proposing it, or a team keeps a mirror. Keep it in its own folder and point it at a checkout.
# The shop's manifest, kept outside the shop. It runs over the clone at ../product.base: maincheckout: ../productoverlay: - { from: standin/serve.mjs, to: rehearse/serve.mjs }services: api: up: node rehearse/serve.mjs --port {{port}} port: auto ready: http://127.0.0.1:{{port}}/healthsignIn: { command: node people.mjs, service: api }people: owner: { default: true } member: {}worlds: stocked: add: node seed.mjs {{api_url}} default: truescenarios: calls: ['./calls/*.hurl'] files: ['./files/*.rehearse.yaml']| Field | Does |
|---|---|
checkout |
The checkout to run in, relative to the manifest. The head is that checkout as it is; the base is a worktree of its base. |
overlay |
Files copied into each checkout after prepare, before anything runs: here a stand-in entry point that runs the product’s own server module. from is relative to the manifest, to to the checkout. |
./ paths |
The scenarios, kept beside the manifest, run on both sides. |
Run Rehearse from the manifest’s folder, or give --manifest from anywhere else.
$ rehearse compare --base main2 as on the base · 2 changed without saying so · 4 fail on the head
changed without saying so: The owner sees every item (./calls/items.hurl:18) $.items[*].price: 3.5 → "3.50" (3 places) …The overlay’s files land in the checkout. Rehearse never counts them as a change, so the head stays clean for the
cache, but git shows them as untracked. Use overlay for what supports a run (a stand-in server, a piece’s preview
module), and ./ paths for scenarios.
Prove it on Kurvball
Section titled “Prove it on Kurvball”The Kurvball example, in examples/kurvball/, runs Rehearse on a real product this way. Its
manifest sits outside the product, with checkout: pointing at a scratch clone (.scratch/kurvball). The files
Kurvball would commit to adopt Rehearse are kept in adopt/, at the paths they would take, such as its stand-in API
and its handoff scenario. prove.sh clones Kurvball from KURVBALL_REPO, a clone you can read, commits adopt/ on
the clone’s main (never pushed), makes a head with head.mjs, and compares, with announce.yaml.
Run the proof from Rehearse’s own repository.
pnpm build # in Rehearse, onceexport KURVBALL_REPO=<url or path> # a clone of Kurvball you can readexamples/kurvball/prove.sh # clones Kurvball, adopts Rehearse, makes a head, comparesWhen the product adopts Rehearse for real, adopt/ and the manifest are committed in it, and checkout: goes away.