Skip to content
Rehearsev1.2.0

Scenarios

A call in the shop fixture checks that the owner sees every item.

packages/api/items.hurl
# The owner sees every item
GET {{api}}/items
Authorization: Bearer {{owner}}
HTTP 200
[Asserts]
jsonpath "$.items" count == 3

rehearse list finds it beside the shop’s other scenarios.

Terminal
$ rehearse list
@shop/api
call packages/api/items.hurl#The shop says it is up
call packages/api/items.hurl#The owner sees every item
…
@shop/report
file packages/report/weekly.rehearse.yaml

A scenario is one thing a person would check, written down so Rehearse can try it. It sits beside the code it tries, in a format people and agents already write. Rehearse runs it, keeps what it saw (an observation), and compares that with what the base saw.

Kind Format What Rehearse observes What the stage shows
piece Storybook CSF (*.stories.tsx) beside the component the accessibility tree, logged errors and axe violations, in each colour scheme; a screenshot kept aside the component live, base and head side by side
flow *.flow.yaml, or a module whose default export is {name, steps} the accessibility tree after each step each step, with the tree and the screen after it
call Hurl’s plain part (*.hurl) beside the handler the status, the content type and the body the request, editable and sent again, and its answer
file *.rehearse.yaml: an input, a command, an output the output file, read by its layout (rows by column, JSON, lines, a zip’s entries) the input and the output’s rows, changed cells marked

The manifest says where each kind lives, with globs:

rehearse.yaml
scenarios:
pieces: ['packages/ui/src/**/*.stories.tsx']
flows: ['**/*.flow.yaml']
calls: ['apps/api/src/**/*.hurl']
files: ['**/*.rehearse.yaml']

* stops at a /; ** crosses folders. Rehearse never looks inside node_modules, .git, dist, build, out, .rehearse and the like. The scenario files reference has every format’s fields. The guides show how to write each: pieces, flows, calls, files.

A scenario’s id is its file, relative to the checkout. When a file holds more than one scenario, the id adds # and the scenario’s name in that file.

Kind Id
piece src/Badge.stories.tsx#Warning (the export’s name)
flow flows/basket.flow.yaml
call packages/api/items.hurl#The owner sees every item (the comment above the call)
file packages/report/weekly.rehearse.yaml

An id is the same on the base and the head, readable in a pull request, and the same word for an agent and a person. A piece’s id uses its export’s name, never its Storybook title, so a story whose title Rehearse can’t read still has an id.

A call with no comment above it is named by its method and URL (GET {{api}}/health). Two calls with the same name in one file are refused, as are two scenarios with the same id.

Rehearse groups scenarios by area: the package a scenario’s file is in (its package.json name), else its first folders. rehearse list, the stage and the comparison use the area.

Path in the manifest Read from So
starts with ./ or ../ beside rehearse.yaml the same file runs on both sides
anything else each checkout each side runs its own definition

One manifest can read scenarios from both places.

rehearse.yaml
scenarios:
calls:
- ./calls/*.hurl # beside the manifest: one definition, run on the base and on the head
- apps/api/src/**/*.hurl # from each checkout: the base runs the base's file, the head the head's

A scenario read from each checkout can be new (the base has no such id) or edited (its own definition changed). A scenario read beside the manifest is never new and never edited: it is the same file on both sides, so only an announcement says it changed. That is how you record today’s behaviour on a base that has never heard of Rehearse: the base runs the head’s definition.

Write piece paths without ./: a piece renders in its own package, which lives in the checkout.

What From
world a flow or a file: its world:, else the default world; a call: the default world; a piece: none
person a call: whom its Authorization names, else nobody; a flow or a file: its person:, else the default person; a piece: none
service a call: scenarios.calls.service, else the default service; a flow: its service:, else scenarios.flows.service, else the default service; a file: its services:

--world, --as and --real on run and compare override these for every scenario in the run.

A scenario fails when what it asks for doesn’t hold. Each kind says what that is:

Kind Fails when
call the service doesn’t answer, the status or an assert doesn’t hold, or a capture finds nothing
file input or run exits with anything but 0, times out, or an output file is missing
flow a step stops: the name isn’t on screen, more than one thing has it, or it doesn’t answer in time
piece it throws, or it never renders

Logged errors and axe violations are observed and compared, never failures. A noisy story can’t hide a real change, and a quiet one doesn’t fail for a warning.

A scenario that couldn’t run at all is different from one that fails. If its service didn’t come up, its world didn’t build, or the sign-in failed, the scenario is listed as not run, with the step and what was said. It gets no verdict. See comparing.

A call whose assert doesn’t hold fails, and rehearse run names the line.

Terminal
$ rehearse run 'packages/api/items.hurl#The count is right'
✗ The count is right (packages/api/items.hurl#The count is right)
on …/shop at dc928d1a5199 · world stocked · as owner
GET /items/count as owner → 200
stand-ins: payments (fake)
line 30: jsonpath "$.count" == 3
expected 3, got 2

Three commands show what Rehearse reads, and run one scenario on its own.

Terminal
rehearse check # reads the manifest and every scenario file; says what it can't read, with the line
rehearse list # every scenario by area, with its kind and id
rehearse run <id> # one scenario on this checkout, as it is now

A file Rehearse can’t read is listed with its line and why, and the rest still run.

Terminal
✗ a.hurl:3: [BasicAuth] isn’t read by Rehearse: it reads Hurl’s plain part

Rehearse v1 runs four kinds. The names job, agent and plan are reserved for later. They are design hooks only:

  • the schemas accept them as kinds;
  • the kind registry takes a runner (how a kind runs and compares) and a view (what the stage shows) for each;
  • the stage already has a place for their view, and shows what was observed for a kind it has no view for.

v1 has no runner for them. A repository can’t add its own kind yet.