Skip to content

Demo ​

waygraph demo plays a flow for a person to watch: one step at a time, with the step panel, rings around what each step touches, captions and a checklist. The flow is the same one run and test play.

sh
npx waygraph demo checkoutFlow               # press Next for each step
npx waygraph demo checkoutFlow --auto-next   # advances by itself
npx waygraph demo checkoutFlow --auto-play-video   # unattended, recorded, headless

What one step shows ​

The before-step panel lists what the step expects (expect: [...]). After it:

  • The outcome card (above the step panel, shown whether the panel is open or not) says how the step went: under Expected, each expectation in words (an Expect Block's description), ticked in turn, or crossed with what the page showed; under Now shows, what the page's read gives that changed since the step before (cart.count 0 > 1; a list by its size); under API calls, each HTTP call the step made (the page's fetch/XHR and an API Block's request) as a row: the method, the route, the status in words (201 Created, 404 Not Found) and the time. Calls to other sites (analytics, a CDN) are counted and left out. A failed step shows the card next to its fail panel.
  • A click on a call row opens the call modal: the request (method, address, headers, body) beside the response (status and why, headers, body), and a Copy as cURL. Credentials (authorization, cookies, fields named like a password or token) are masked. The same calls are in the run log (step:call).
  • The rings show what the step's checks looked at, labelled in words: an expectation's description, or what the check looked for (shows, reads "Saved"; a custom Trait's says). Something no longer on the page (a check made before the step went to another page) gets no ring.
  • Its Expect Blocks' own narration plays: its slides, then its rings, a case's to-do marked, a caption.
  • The panel's The page shows section lists every value the page's read gave.

Narration lives in the flow ​

Blocks stay neutral. A flow narrates a Block where it uses it, by chaining stubs on it, so two flows can tell the same Block's story differently.

ts
const SubmitLogin = SubmitLoginBlock
  .stubBefore((ctx) => {
    ctx.ui.ring("username", { selector: LoginSel.username, label: "Demo user", detail: "standard_user from mem", tag: "AC" });
    ctx.ui.ring("submit", { selector: LoginSel.loginButton, label: "Sign in", tag: "GATE" });
  })
  .stub((ctx) => ctx.ui.ring("badge", { selector: InventorySel.list, label: "Signed in", tag: "AC", duration: true }));

export const loginFlow = engine
  .map()
  .gotoPage(NavLoginBlock.stubBefore((ctx) => ctx.ui.title("Sign in")))
  .method(FillUsernameBlock)
  .method(FillPasswordBlock)
  .method(SubmitLogin);
StubRunsShow
stubBeforebefore the step actsthe fields and buttons it will touch
stubafter it lands and its checks passthe proof: AC, GATE
stubOnErrorwhen it failswhat was on screen at the failure

A stub that throws fails its step, named (add-item: its stub threw: …), so a typo shows up on the fail panel instead of the narration quietly missing. A stub is a function of ctx: share one like any function (src/stubs/).

ctx.ui ​

CallPaints
ring(id, { selector, label, detail?, tag?, tone?, duration? })a ring around an element, with a caption: [TAG] label - detail
title("Checkout")the banner at the top: the flow's name from this step on
caption("Enter the first name") / hideCaption()a narration card at the bottom (stays until changed)
todos(id, items, { title, index })a floating checklist (acceptance criteria, say)
slides([{ caption, selector?, tone? }, …])several captions in turn, each waiting for Next
device("mobile") / hideDevice()the page at a phone or tablet size, with touch
zoom(1.5)zooms the page in
showNetworkTab() / hideNetworkTab()the network panel: requests, status, bodies, Copy as cURL
showCalls()in a stub: opens the step's first HTTP call in the call modal (request and response), for a recording nobody clicks through

When the steps end, the overlay clears and a card says the demo is done and how it went: Finished (or Finished as expected, for a flow that's meant to fail), or Stopped with the step and the reason; the flow's title, and how many steps in how long. It stays a moment (a short one with --fast) before the page closes, so a recording ends on it.

The step panel, the banner, the caption, the checklist, the device and the outcome card stay through a navigation: a step that goes to another page or site (a redirect, a login, a payment provider) shows them there as they were, until a stub changes them.

tone is "info", "success", "warning" or "danger". Blue rings are yours; grey ones are waygraph showing what a step does on its own (a fill, a click, a check), so the blue stands out.

Don't hand-write UI ​

Everything a demo shows goes through ctx.ui. Don't build banners or highlight boxes in the page (page.evaluate + createElement, innerHTML, addStyleTag) or restyle waygraph's overlay (#wg-*, .wg-*):

WhyBecause
it changes the page under testan injected banner can cover a button; a style can hide the bug
it breaks silentlyoverlay ids and classes are internal and change between releases
it already existsctx.ui covers it, and survives navigation

waygraph check warns on it (hand-written-ui). If ctx.ui is missing something, that's a feature to ask for.

The checklist ​

ctx.ui.todos floats beside the panel. By default it folds to about five rows around the current one, moves to the other side when a ring would sit under it, and dims while a ring is up.

Turn offWith
all three, for the run--todo-full
one, for one stepctx.ui.todoDockUi({ compact: false, collision: false, behindRing: false })
pin a side--todo-left / --todo-right

Locked while it plays ​

A demo locks the page against the person watching it, so a stray click can't change what the steps expect. A small locked chip in the bottom-left corner says so; click it to unlock the page (it says unlocked) and again to lock it. The step panel's Next, Retry and Stop always work. Waygraph's own steps act through the lock.

Pace ​

SettingWhere
the whole demo--fast, or demo: { pace: "fast" } in the config
one flowmap({ demoPace: "slow" })
one step.method(SetBearerTokenBlock, { pace: "blitz" }) (no typing animation, no pause)
a group of steps{ ff: true } on each, or fastForwardComposeBlock: one panel, full speed

Paces are "blitz", "fast", "normal", "slow", or a number (0.5 = twice as fast; above 20 it's milliseconds). --ff-disabled opens every fast-forward group up into its steps, to see which one broke.

What the overlay shows ​

By default a demo shows everything: the title, the step panel, the rings on what each step checked and the card of what was expected and what the page now shows, the checklist. A demo for an audience that only needs the app, the mouse, the keyboard and the captions leaves the rest out:

ts
demo: {
  overlay: { banner: false, panel: false, checks: false },   // and todos: false; each is on unless set false
},
PartIs
bannerthe title at the top
panelthe step panel (the step, Next, the progress). Without it the demo moves on by itself, slides show as captions (held as long as they're read or spoken), and a failed step still shows its panel
checksthe rings on what each step's checks looked at, and the card of what was expected and what the page now shows
todosthe checklist docks (ctx.ui.todos)

The cursor, the typing, the rings on what a step clicks or fills, and the captions always show.

What stays on screen stays put between steps on one screen: the title, the panel, the caption and the card don't go and come back (which a viewer reads as "something new"), and a step that takes a screenshot (screenshot: true) takes it with the overlay in it rather than hiding it. A page load starts a new document, so the overlay paints again, at once and without sliding in. WAYGRAPH_OVERLAY_TRACE=1 logs each part showing and going, and how often each one blinked.

Voice-over ​

A recording lands in the video folder under the name its flow gives it (map({ video: "auth/{label}/{title}" }), Flows).

A recorded demo (--video) can speak its narration. Give the demo a voice in the config, and each caption and slide is spoken as it shows; the recording gets the speech as its audio track and its subtitles beside it (<video>.vtt):

ts
// config/waygraph.config.ts
import { defineConfig, kokoroVoice } from "waygraph";

const config = defineConfig({
  baseUrl: "https://www.saucedemo.com",
  demo: {
    voice: {
      speaker: kokoroVoice(), // af_heart; kokoroVoice({ voice: "am_michael", speed: 0.95 })
      steps: true,            // also each step's description
    },
  },
});
sh
npx waygraph install        # once per machine: Kokoro and its model (~350 MB, in waygraph's cache)
npx waygraph demo checkoutFlow --auto-play-video
# waygraph: voice-over: 14 lines, subtitles .../page@8c26....vtt

The voice is heavy (a model), so it isn't part of waygraph's install, and the waygraph package stays as it was: waygraph install sets it up for every project on the machine, next to the browser extensions, the same way: named in the config, fetched by one command, --update to fetch it again.

Where~/.cache/waygraph/voices/kokoro/ (WAYGRAPH_CACHE_DIR moves it): a Python environment (venv/, ~150 MB), the model (kokoro-v1.0.onnx, 326 MB), its voices (voices-v1.0.bin, 28 MB), and installed.json, what was set up. One copy for every project
.envwaygraph install lists what the voice reads in .env.example and .env, blank and commented: # OPENAI_API_KEY= for openAIVoice(), # WAYGRAPH_CACHE_DIR= for Kokoro
Not set up yetwaygraph demo --video records without the voice-over and says, once, recording without the voice-over: Kokoro isn't set up on this machine: run waygraph install. Nothing fails; only --video demos ever speak
A new waygraph, a new KokoroEach waygraph pins the Kokoro it speaks with (the package version and the model release). After an upgrade that moves it, a recording says the Kokoro on this machine is another version than this waygraph uses; waygraph install replaces it (the environment again, a new model downloaded, the old one removed). Lines already spoken are cached by voice and model, so a new model makes them again
Speaker
kokoroVoice()Kokoro, natural and local (CPU is enough). Its model is loaded once and kept for the recording. waygraph install sets it up (a Python environment through uv when there is one, and the model); or name your own python, model and voices. Voices: af_heart (default), af_bella, am_michael, bf_emma...
commandVoice("piper --model x.onnx --output_file {out}")a local text-to-speech command: {out} is the file it writes, {text} the line (without {text}, the line goes to its stdin). piper sounds natural and runs offline; espeak-ng -w {out} {text} is on most Linux machines; on macOS, say -o {out} --data-format=LEI16@22050 {text}
openAIVoice({ voice: "nova", instructions: "Calm and clear." })an OpenAI-compatible speech API (OPENAI_API_KEY, or apiKey; baseURL for another server that speaks the same API, a local one too)
your own{ id, ext, synthesize(text, out) }: write text, spoken, to the file out
  • What's spoken: a new caption (ctx.ui.caption) as it shows, each slide (its caption, then its detail) and, with steps: true, each step's description as its panel comes up. A caption painted again unchanged isn't spoken again. Arrows and separators are read as words (Cart -> info is "Cart to info"); the screen shows them as written.
  • Timing: lines are spoken one at a time, never over each other, with a breath between them, and auto-advance waits for a line to end before moving on, so the voice is never cut off. A slow voice makes a longer video, not a clipped one. With steps: true, the steps' descriptions are made while the first steps play, so a first recording doesn't stop to make them.
  • Cache: each line is made once per voice and text, in .waygraph/voice/; a second recording of the same flow doesn't call the voice again.
  • Needs ffmpeg (and ffprobe) on the PATH. Without it the demo records silent and says why. A line the voice fails on is left out, naming it; the rest are kept.

Only a recorded demo speaks: waygraph run shows no narration, and a demo without --video has nothing to put the speech on. --no-voice records without it.

Flags ​

FlagDoes
--auto-nextadvances by itself
--fastshorter pauses and cursor moves
--fullevery step as a chip, instead of the carousel
--video [dir]records a .webm (default ~/Downloads/waygraph-videos/<project>)
--auto-play-video--auto-next --video, headless
--auto-play-video-headthe same, with the browser visible
--no-voicerecords without the config's voice-over
--split windowsa flow with panes in windows side by side, instead of on one stage (Split view)
--video-panesa flow with panes: also a video of each pane
--compare as=a,bthe flow twice, side by side, and where the two differ (device=…, config=… too)
--data / --input / --replaythe flow's data (Data)

waygraph demo --help prints every flag; environment variables lists what each one sets. demo.appearance: "light" | "dark" in the config pins the overlay's look, so recordings match whichever machine makes them.

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed