Skip to content
Rehearsev1.2.0

Scenario files

Rehearse finds scenario files with the globs under scenarios in rehearse.yaml, and reads each by its kind. It never runs a file to read it. A file it can’t read is refused, with its line when it knows it, and rehearse check lists every refusal.

Kind File Id Compared
piece Storybook CSF: *.stories.tsx <file>#<Export> The accessibility tree, logged errors, axe violations
flow *.flow.yaml, or a reach module <file> The accessibility tree after each step, logged errors
call Hurl’s plain part: *.hurl <file>#<name> Status, content type and body
file *.rehearse.yaml <file> The exit code, and each output by its layout

<file> is the path relative to the checkout, with forward slashes. For a file read beside the manifest (a glob that starts with ./ or ../), it is relative to rehearse.yaml and starts with ./ or ../. Ids are the same on the base and on the head, so a comparison pairs them. When two scenarios have the same id, the second is refused.

Each scenario also has an area, where rehearse list and the stage group it: the name in its package’s package.json, else its package’s folder, else the first one or two folders of its path. A package is the nearest folder with package.json, pyproject.toml, Cargo.toml or go.mod.

A scenario fails on its own checks. What it observes is compared, and a difference is never a failure on its own.

Kind Fails when
piece It throws, or doesn’t render within 20 seconds, in a scheme. Its logged errors and axe violations are compared, never failures.
flow Its page doesn’t open, or a step stops: nothing has the name, more than one has it, or it didn’t answer in time.
call It gets no answer, a status or an assert doesn’t hold, a capture finds nothing, or no one signed in as its person.
file input or run exits non-zero or times out, or an output is missing.

A piece is one story of a Storybook CSF file, beside its component. The following file holds three pieces.

src/Badge.stories.tsx
import { fn } from 'storybook/test';
import { Badge } from './Badge';
const meta = { title: 'Pieces/Badge', component: Badge, args: { label: 'New', onSeen: fn() } };
export default meta;
export const Primary = {};
export const Warning = { name: 'A warning', args: { label: 'Low stock', tone: 'warning' } };
export const Dated = {
render: () => <p>Updated {new Date().toISOString().slice(0, 10)}</p>,
};

rehearse list shows each story as a piece.

Terminal
$ rehearse list
src
piece src/Badge.stories.tsx#Primary
piece src/Badge.stories.tsx#Warning
piece src/Badge.stories.tsx#Dated

Warning’s name is Badge · A warning; its id stays src/Badge.stories.tsx#Warning.

Rehearse reads the file as text, without running it.

  • Stories are the named exports: export const, let or var (each name of export const A = {}, B = {}), export function, export class, and the names in export { A, B as C }. Not default, not a name that starts with __, and not a type: export type, export interface and export { type X } are skipped.
  • includeStories and excludeStories in the meta are honoured when written as a list of names or a regular expression.
  • The title is the meta’s title when it is a plain string, in export default { title } or in the object the default export names (const meta = { title }; export default meta). Otherwise it comes from the path: without a leading src/ and the extension, and without a last part named index or named like its folder.
  • The name is the story’s own name: '…', else a legacy Story.storyName = '…', else the export’s name in words (PrimaryButton becomes Primary Button). The scenario’s name is the title’s last part, ·, then the name.
  • The id is <file>#<Export>. It never depends on the title. When the title can be read, the observation also carries Storybook’s own id, storyId (pieces-badge--a-warning).
  • The definition that marks a piece edited is its own export’s statement and the meta’s text (the default export, and the object it names). The file’s imports aren’t part of it. Editing one story, or adding an import for a new one, doesn’t mark the others edited.
  • In its own package. The package is the nearest folder at or above the story, up to the checkout, that has a package.json and resolves both vite and react. Rehearse starts that package’s own Vite and React on 127.0.0.1. A story with no such package isn’t run, and Rehearse says why (step runner).
  • Vite config: scenarios.pieces.config, else vite.config.*, else vitest.config.* in the package.
  • Styles: scenarios.pieces.styles, else a .css file the package exports (./styles.css, ./style.css, ./styles and ./style first), else src/styles.css, else src/index.css.
  • Preview: scenarios.pieces.preview, a Storybook-style preview module relative to the package. Its named exports and its default export are both read: args, argTypes, parameters, initialGlobals (or globals), decorators, loaders and render.
  • Composition, as Storybook does it: args are the preview’s, then the meta’s, then the story’s. Decorators wrap the story’s first, then the meta’s, then the preview’s. Loaders (the preview’s, the meta’s, the story’s) run before the story renders and fill context.loaded. The render is the story’s, else the meta’s, else the preview’s, else the meta’s component with the args. A story that is a function is its own render.
  • play functions are not run.

Storybook’s runtime modules don’t exist outside Storybook, so Rehearse answers these imports with small stand-ins:

Import What Rehearse gives
storybook/preview-api, @storybook/preview-api, @storybook/client-api, @storybook/addons, @storybook/manager-api useArgs (the args, updateArgs, resetArgs; updating re-renders), useGlobals, useParameter, useStoryContext, useChannel, React’s hooks, an addons channel that does nothing, makeDecorator, definePreview, composeStory, setProjectAnnotations.
storybook/test, @storybook/test fn(), a mock that records its calls; spyOn, mocked, isMockFunction and the *AllMocks helpers; expect, userEvent, screen, fireEvent, within and waitFor as inert stand-ins.
storybook/actions, @storybook/addon-actions action() and actions(), which do nothing.

Each scheme in scenarios.pieces.schemes (default light) renders in its own browser context: viewport 1024×768 unless viewport says otherwise, reduced motion, and a clock fixed at 2026-01-15T12:00:00Z, so a date on screen reads the same on both sides. Rehearse waits until the piece mounts and its accessibility tree stops changing.

Observed What it is
tree The accessibility tree of the story’s root, as Playwright’s ARIA snapshot gives it.
threw Why it didn’t render: what it threw, or that it never rendered. null when it rendered.
errors What the page logged as errors, or threw, while rendering.
violations axe-core’s violations of the rules tagged wcag2a, wcag2aa, wcag21a, wcag21aa and wcag22aa: each rule’s id, help and how many nodes.
pixels A hash of the screenshot. The screenshot itself is kept as an artifact.

scenarios.pieces.compare chooses what is compared: tree, errors and violations by default; screenshot compares pixels, and only when you name it, since pixels differ across machines.

A flow is steps by accessible name, from a service’s page or a piece’s canvas. Rehearse observes the accessibility tree after each step. The following flow opens the member directory and searches it.

flows/members.flow.yaml
name: The owner opens the member directory
service: api
start: /members
world: one-org
person: owner
steps:
- click: Members
role: link
- fill: Search
with: creator
- key: Enter
- snapshot: Members
role: table

The schema is schema/v1/flow.schema.json. A file whose name ends in .yaml or .yml is read as YAML.

Field Type Default What it is
name string, required What the flow tries, in plain words. Up to 120 characters.
describe string none More words.
service service name scenarios.flows.service, else the default service The service whose page it opens.
piece piece id none Or a piece whose canvas it opens, for a screen that renders only as a story.
start path / The path it opens on the service, such as /settings.
world world name defaults.world The world it starts from.
person person name defaults.person Who it runs as.
covers globs none Files whose change reaches it, for --affected.
steps list, required 1 to 60 steps.

The flow’s id is its file. Its definition (what marks it edited) is its service, piece, start, world, person and steps.

Each step has exactly one verb.

Step Also takes What it does
click: <name> role Clicks the one element with that accessible name.
fill: <name> with, role Fills that field with with. In Rehearse’s browser only. with can use {{token}}.
type: <text> Types the text into whatever has focus.
key: <key> Presses a key.
snapshot: <name> role Observes the tree of that one element.
  • A name is an accessible name, as a screen reader says it, up to 120 characters. It matches when it is the same once spaces are tidied; case counts. When nothing matches, the failure lists up to five names close to it. When more than one matches, add role.
  • A role is an ARIA role, as Playwright’s getByRole takes it: button, link, textbox, heading, table, switch, and the rest of the list in the schema.
  • A key is named as Playwright names it: Enter, Escape, Tab, Backspace, Delete, Space, the arrows (ArrowUp…), Home, End, PageUp, PageDown, F1 to F12, one lower-case letter or digit, or one of , . / ; ' ` [ ] \ = -. Modifiers come first, joined by +: ControlOrMeta, Meta, Control, Alt, Shift. So Meta+k and ControlOrMeta+Shift+p.

Each action may take 5 seconds. After each step, Rehearse waits until the page’s tree stops changing (up to 4 seconds), then observes it.

A reach script is read the same way: a TypeScript or JavaScript module whose default export is a flow, { name, steps }, as Ashlar writes them. Rehearse reads the export as data: it never runs the module. The following module is one flow.

flows/settings.reach.ts
export default {
name: 'Settings',
service: 'desk',
steps: [
{ click: 'Ask before closing', role: 'switch' },
{ snapshot: 'Ask before closing', role: 'switch' },
],
} as const;
  • The default export is export default { … }, or const x = { … }; export default x.
  • It holds plain literals only: strings, numbers, booleans, null, arrays and objects. Keys are names or strings. Comments are fine.
  • After the object, only satisfies <Type>, as const, a semicolon or the end of the line may follow.
  • Anything else is code, and refused with its line: a template with ${…}, a shorthand { name }, a spread, a call, a variable.
  • Rehearse reads name, steps, service, piece, start, world, person and covers from it.

rehearse check ends with one line per file it refused, such as this one for a module that holds code.

Terminal
✗ flows/settings.reach.ts: Rehearse reads a flow module’s default export as plain data, and couldn’t: line 3: “name” needs a value after a colon (a shorthand is code, not a literal).
  • In Rehearse’s browser, a headless Chromium on a clock fixed at 2026-01-15T12:00:00Z. It signs in as the person with their browser entry: headers, storage and cookies first, then any sign-in steps on the service’s own page. Then it opens start on the service’s URL and observes the tree (step 1, open), then each step (steps 2 onwards). A screenshot after each step is kept as an artifact.
  • On a piece’s canvas, when the flow names piece. No sign-in steps run there.
  • Through the service’s own driver, when its service has drive. Rehearse passes each step through and takes a nameless snapshot after each action. fill is refused: click the field, then type. The driver can’t sign in as a person, and the result says so. Between flows, Rehearse runs the world’s before, brings the app up afresh, then runs the world’s add, so each flow starts where its world starts. That needs a down command and an up that hands over to a daemon; without them, flows share the app, and said says so.

A comparison compares the number of steps, whether each step held, each step’s tree, and the errors the page logged (in Rehearse’s browser), after what is set aside.

A call is one HTTP request in Hurl’s plain part, beside its handler. Each call is one scenario. The following file holds three calls.

calls/items.hurl
# The owner sees every item
GET {{api}}/items
Authorization: Bearer {{owner}}
[Query]
limit: 10
[Options]
retry: 3
retry-interval: 500
HTTP 200
Content-Type: application/json
[Captures]
first: jsonpath "$.items[0].id"
[Asserts]
jsonpath "$.items" count >= 1
jsonpath "$.items[?(@.name == 'Pen')]" count == 1
jsonpath "$.next" == null
duration < 2000
# One item, by its id
GET {{api}}/items/{{first}}
Authorization: Bearer {{owner}}
HTTP 200
[Asserts]
jsonpath "$.id" == "{{first}}"
jsonpath "$.name" matches /^[A-Z]/
header "Content-Type" startsWith "application/json"
POST {{api}}/items
Authorization: Bearer {{member}}
{"name": "Ink"}
HTTP 403

rehearse list shows each call by its name, or by its request line when it has none.

Terminal
$ rehearse list
calls
call calls/items.hurl#The owner sees every item
call calls/items.hurl#One item, by its id
call calls/items.hurl#POST {{api}}/items
  • A call’s name is the comment on the line just above its request line. Without one, it is the method and URL as written. Two calls with the same name in one file are refused.
  • Its id is <file>#<name>, and its line is the request line.
  • It is sent as the person its Authorization header names: Authorization: Bearer {{owner}} sends it as owner, with the token the sign-in gave. A call with no Authorization is sent as nobody. One whose Authorization names no variable is sent with “a token for no one”.
  • --as <person> replaces the Authorization header with Bearer {{<person>}}; --as nobody removes it.
  • A call sent as a person no one signed in fails, naming who was.
  • {{api}}: the URL of the calls service (scenarios.calls.service, else the default service), without a trailing slash.
  • {{<person>}}: each signed-in person’s token.
  • The sign-in’s variables, including <person>_<field>.
  • scenarios.calls.variables.
  • {{checkout}}, {{manifest}}, {{url}}, {{world}}, and each running service’s {{<service>_url}} and {{<service>_port}}.
  • Captures from earlier calls in the file.

A variable with no value fails the call: {{first}} has no value.

Part What Rehearse reads
Request line GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS, then the URL.
Headers Name: value lines after the request line.
[Query], [QueryStringParams] key: value lines, added to the URL.
[Options] retry: <n> (0 to 60) and retry-interval: <ms> (or <n>s; default 1000 ms).
Body The lines after the headers: JSON or text. Or a fenced block between ``` lines (```json too).
Response line HTTP <status>, HTTP/1.1 <status>, or HTTP * for any status.
Response headers Name: value lines after it, each checked as header "Name" == "value".
[Captures] name: <query>. The value is a variable for later calls.
[Asserts] <query> [not] <predicate> [<value>].
Query Gives
status The status code.
header "<name>" That header’s value.
body The body as text.
duration How long the answer took, in ms.
jsonpath "<path>" A value from the JSON body. Paths: $, .key, .*, [0] (negative too), ['key'], [*], and filters [?(@.key == value)] or !=. Not ...

A query may end with the filter count: the number of items in a list.

Predicates: ==, !=, >, >=, <, <=, contains, includes, startsWith, endsWith, matches, exists, isString, isInteger, isBoolean, isCollection, isEmpty, isUuid, isIsoDate. Values: "a string", /a regular expression/, a number, true, false, null, or {{variable}}.

Anything beyond the plain part is refused by name, with its line, so you know what to change:

  • other sections: [FormParams], [MultipartFormData], [Cookies], [BasicAuth] and the rest;
  • other options than retry and retry-interval;
  • other queries, such as xpath, cookie or sha256;
  • other filters than count: nth, regex, split, replace, toInt, jsonpath, xpath and the rest;
  • predicates it doesn’t know, and values it can’t read;
  • file,, base64,, hex,, XML and one-line ` bodies;
  • any line before the first request that isn’t a comment.

rehearse check lists each refusal with its file and line, such as these two.

Terminal
✗ calls/items.hurl:5: the filter nth isn’t read by Rehearse
✗ calls/login.hurl:3: [FormParams] isn’t read by Rehearse: it reads Hurl’s plain part
  • A file’s calls run in order, so captures carry from one to the next. To run one call, every call before it in its file runs first, since its answer can depend on what they did; the observation counts them in before.
  • Each call may take 15 seconds. Redirects aren’t followed. A body that starts with { or [ is sent as application/json, any other as text/plain, unless a Content-Type header says otherwise.
  • With retry, a call that fails is tried again after retry-interval, up to retry more times. tries then lists each try’s status.
  • A call’s definition (what marks it edited) is its own request, status, asserts, captures and options, and those of the earlier calls whose captures it uses.

A comparison compares the status, the content type, and the body (as text when both bodies are text, else as JSON), after what is set aside. Arrays keep their order unless scenarios.calls.unordered is true.

A file scenario is an input, a command that turns it into output, and the output, compared by its layout. The following scenario turns a stock file into the weekly report.

packages/report/weekly.rehearse.yaml
name: The weekly stock report lists every item with its price
input:
file: stock.json
run: node packages/report/report.mjs {{input}} {{output}}/weekly.csv
output:
file: weekly.csv
layout: csv

The schema is schema/v1/file-scenario.schema.json. The scenario’s id is its file.

Field Type Default What it is
name string, required What it tries, in plain words.
describe string none More words.
world world name defaults.world The world it starts from.
person person name defaults.person Who it runs as: their token is {{token}} and $REHEARSE_TOKEN.
services service names none Services that must be up while it runs.
covers globs none Files whose change reaches it, for --affected.
input map none file: a file beside this one. Or command: a command that writes {{input}}, and name, that file’s name (default input).
run command, required Turns the input into the output.
cwd path the checkout Where input.command and run run, relative to the checkout.
env map none Environment variables. Values take placeholders.
timeout seconds 120 How long input.command and run may each take.
output one output, or a list required What run writes, and how to read it.
setAside map none columns never compared; values, more regular expressions to set aside; keep, columns or JSON paths never set aside.

Placeholders: {{input}} (the input file), {{output}} (a scratch folder for the output), {{here}} (this file’s folder), {{checkout}}, {{manifest}}, {{world}}, {{person}}, {{token}}, {{url}}, each running service’s {{<service>_url}} and {{<service>_port}}, and the sign-in’s variables. input.command and run also get REHEARSE_INPUT, REHEARSE_OUTPUT and, when the person has a token, REHEARSE_TOKEN.

The definition that marks it edited is its parsed YAML and the content of its input.file.

Field What it is
file Required. The output file, relative to {{output}}, unless it is an absolute path such as {{checkout}}/out/report.csv.
layout Required. csv, tsv, json, lines, fixed or zip.
header csv and tsv: whether the first row names the columns. Default true.
columns csv and tsv without a header: the columns’ names. fixed: each column’s name, start (from 1) and width.
unordered Compares rows, or array items, without their order.
entries zip: the layout of each entry, by glob: csv, tsv, json, lines, zip or skip.
Layout How it is read and compared
csv Rows and cells as RFC 4180 reads them: quotes, doubled quotes, line breaks inside quotes. Compared by column name.
tsv The same, split on tabs.
fixed Each line cut into the named columns, each cell trimmed. Compared by column name.
json Parsed, then compared as JSON with what is set aside. Text that isn’t JSON is read as lines.
lines Each line, compared as text.
zip Each entry by the first glob in entries that matches its name, else as lines. zip reads an archive inside the archive, such as a Word file; skip compares only that the entry is there, for files that carry their own render time, such as a PDF.

A file that isn’t text is read as one line with its size and hash. Columns without a header are named column 1, column 2, and so on. Empty lines are dropped from csv, tsv and fixed. In a zip, an entry of an archive inside the archive is named <outer>!<inner>, and entries globs match that name. Rehearse reads stored and deflated entries.

Changes to a table are grouped by column, with a count. rehearse compare prints such a change as one line.

Terminal
weekly.csv column 3 "price": "3.5" → "3.50" (2 places)

A comparison also compares the exit code, the columns, and the number of rows.

An announcement says which scenarios a change expects to change, each with one line saying why. The following announcement names one call and every story of one file.

.rehearse/announce.yaml
changes:
- scenario: 'apps/api/src/routes/members.hurl#A creator is told they may not see the directory'
why: A creator now gets 403 forbidden instead of the concealed 404.
- scenario: 'packages/ui/src/Badge.stories.tsx#*'
why: Badges use the new colour tokens.

The schema is schema/v1/announce.schema.json. It may be YAML or JSON, and may carry v: 1.

Field What it is
changes Required. A list.
changes[].scenario A scenario’s id, or a glob over ids: * stops at /, ** doesn’t. packages/ui/src/Badge.stories.tsx#* covers every story in that file.
changes[].why One line: what changes, and why.

rehearse compare reads .rehearse/announce.yaml beside rehearse.yaml when it is there, or the file --announce names. --said <id> announces one more from the command line.

  • A scenario that changed and is announced is changed and said so (said: "announced", with why). An announcement wins over an edited definition, since it carries why.
  • An announced scenario that didn’t change is listed under announced, but as on the base: a note, never a failure.
  • An announcement doesn’t excuse a scenario that fails on the head.
  • In a comparison of every scenario, an entry that names no scenario at all (none compared, gone or not run) is listed under refused: “The announcement names X, which matches no scenario compared.” It doesn’t change the exit code.
  • An announcement that doesn’t meet the schema stops the comparison, naming its line (code announce).