Skip to content

Your project ​

A waygraph project has one shape. Every project puts the same things in the same places, so a person or an agent who knows one project knows where to look in the next. This page is that shape, and the opinions behind it: each comes with why, and with what holds you to it.

npx waygraph init my-app makes a small project in this shape that works offline: npm test passes as soon as it is installed.

The shape ​

sh
my-app/
├── config/
│   └── waygraph.config.ts          # baseUrl, webServer, device, labels, demo; exports `engine`
├── src/
│   ├── accounts/                   # the people the app knows: account("planner", { signIn, mem, ttl })
│   ├── states/                     # mem keys with their stubs (*.mem-keys.ts); a page is its own Checkpoint
│   ├── map/                        # the app, page by page: folders are its addresses
│   │   ├── (main)/                 # the app under test (groups: not part of any address)
│   │   │   ├── (app_base)/         # its pages
│   │   │   │   ├── _sel.ts         # the layout's selectors
│   │   │   │   ├── home/           # the page at /home
│   │   │   │   └── platform/
│   │   │   │       └── equipment/      # the page at /platform/equipment
│   │   │   └── (api)/              # its API Blocks, a folder per resource
│   │   └── (external)/             # other sites a flow visits: a mail catcher, a REST client
│   └── flows/                      # use cases: a folder per page, like src/map/
│       ├── auth/login/
│       │   ├── success.flow.ts     # one file per outcome: loginSuccessFlow
│       │   └── wrong-password.flow.ts
│       └── (user-stories)/         # stories across pages
├── tests/                          # Playwright specs, only for what a flow can't say
├── .env.example                    # what the config reads, blank and commented
└── .agents/skills/                 # how-to for coding agents

There is no playwright.config.ts: waygraph test builds it from config/waygraph.config.ts (Config).

One page folder ​

Every page folder uses the same file names. Start one with waygraph gen page <path> --do a,b (Generate), then fill in the selectors:

FileHoldsMade with
_page.block.tsthe page: how it opens (url, from), what it shows (read), what you can do (do), what you can expect (expects), who can open it (for)definePageBlock
_sel.tsevery selector this page usesa plain object of strings, or typed sel.* builders
_methods/one action per file: fill, click, submit: a function of its page, (self: PageHandle<"Home">) => self.method({ … }), listed in the page's dopage.method
_expect/what a scenario can expect on this page, one per filedefineExpectBlock

A leading _ means "this page's own machinery". A folder name without one is a child page with its own address segment. A page that covers its children is the shell of every page under its folder (Layouts).

Generate ​

waygraph gen writes files from the convention, so every page, Method and flow starts the same shape, whoever writes it. It never overwrites a file, and ends by writing the page names so what it made completes.

sh
npx waygraph gen page login --read error --do fillEmail,submit   # _page.block.ts, _sel.ts, _methods/fill-email…, _methods/submit…
npx waygraph gen page "requests/[id]" --query tab --from Dashboard # a page with a [id] (Page.go({ id })), opened from Dashboard
npx waygraph gen page dashboard --shell                          # a page that covers its children (a sidebar, a top bar)
npx waygraph gen method login fillPassword                       # one more Method: its file, its entry in do, its selector
npx waygraph gen flow login/success                              # src/flows/login/success.flow.ts over the page's moves
npx waygraph gen keys signup email,name                          # src/states/signup.mem-keys.ts
npx waygraph gen account owner                                   # src/accounts/owner.ts

Every selector it writes is "TODO": fill them in, and waygraph check lists the ones left. --inline writes Methods in the page instead of _methods/, --group "(external)" picks the map group, --name RequestDetail names a page whose path's name is awkward (requests/[id] is RequestsId), --dry prints what it would write.

The opinions ​

OpinionWhyWhat holds you to it
Folders under src/map/ are the app's addresses. /platform/equipment lives in map/(main)/(app_base)/platform/equipment/; (group) folders only organise.The tree is the site map: nothing to keep in sync, and anyone who knows the app's URLs finds the page.waygraph map fails on a folder that doesn't match its page's address
A Checkpoint is a page, a place with its own address. An item in the cart is what the page shows, not another Checkpoint.Fewer, truer Checkpoints; flows check the state with Key.iswaygraph check names a Checkpoint that is a state of a page
Every page has a read.Runs, agents, tests and Waygraph Studio read the page as data, not by parsing the DOMwaygraph check lists the pages with no read
One action per Block, its selectors in _sel.ts.One Block, reused by every flow that needs it; a changed selector is changed oncewaygraph check: a fill and a click in one Block, several inputs in one Block, an inline selector when a _sel.ts is there
Navigation happens in Navs.The map knows every way between pages; a Method that navigates is a hidden edgewaygraph check warns on page.goto outside a Nav
What every page shares is a layout, in the folder of the pages it wraps. Never the same Nav on each page, never a list of pages on a Nav.Declared once, where front-end developers look for ita layout link from a page it doesn't cover fails before clicking
Who sees what is for: [accounts], on the link, the Method or the page.Access is written beside what it's about, and tested without a testwaygraph test --flows adds each account's access test; waygraph check flags a flow as an account using what it isn't given
A flow that starts signed in runs as an account. Never a login copied into each flow, never cookies by hand.One sign-in, kept and reused across flows and workersthe account's session is kept for you; a hand-saved session has no reason to exist
A flow imports pages, not Blocks: Page, Page.do.x, Page.expects.y. Imports use #config/, #map/, #states/.A flow reads like the scenario; no ../../..TypeScript: a step must start where the last one ended
verify is the Block's own check; expect is the scenario's. Expectations only read.A Block is true wherever it's used; a scenario says what it expects in one placewaygraph check: an arrival check in an Expect Block, an outcome in a Method's verify, an expectation that acts
Flows are the tests: a folder per page (mirroring src/map/), one file per outcome, exported as <page><Outcome>Flow; stories across pages in a (group); groups of flows are labels in the config.A page's folder shows every way through it; nothing to write twice; --label auth runs a featurewaygraph test --flows runs every exported flow; waygraph check warns about a label that covers no flow
Data is named, never hidden: a mem key per value, a mem stub for fake ones, unique for what must be new each run.A run says what it was given and replays with itwaygraph check warns when a Block that creates something gets the same data every run
No fixed waits, no retry loops, no hand-built demo UI.Traits already retry; the demo already narrateswaygraph check: a retry loop by hand, hand-written overlay UI
Nothing is imported for its side effect.The tools load Blocks, pages, stubs, accounts and layouts themselvesthe tools find them by name and folder

waygraph check only warns; waygraph map and TypeScript fail. In CI run all three (Testing).

Imports ​

package.json gives the project's folders short names (Node's own subpath imports, which TypeScript and the test runner resolve too):

json
"imports": { "#config/*": "./config/*.ts", "#states/*": "./src/states/*.ts", "#map/*": "./src/map/*.ts" }
ts
import { engine } from "#config/waygraph.config";
import { HomePage } from "#map/(main)/(app_base)/home/_page.block";
import { TopBar } from "#map/(main)/(app_base)/_page.block";

Flows are use cases ​

src/flows/ follows the pages too, but it holds the stories, not the parts: a folder per page, one file per outcome.

PathHoldsExport
flows/auth/login/success.flow.tsone page, one outcomeloginSuccessFlow
flows/auth/login/wrong-password.flow.tsthe same page, another outcomeloginWrongPasswordFlow
flows/(user-stories)/checkout.flow.tsa story across pagescheckoutFlow

A page's folder shows every way a user can go through that page; the manifest and Waygraph Studio read the use case from the path (the page, then the outcome).

ts
// config/waygraph.config.ts
labels: ["smoke", { name: "auth", flows: ["src/flows/auth/**"] }, { name: "checkout", flows: ["src/flows/checkout/**", "checkoutFlow"] }]

waygraph test --label auth runs a feature; a flow's labels are its tags in Playwright's reports and in Waygraph Studio.

What to do where ​

I want to...Do this
add a pagecopy a page folder, keep the _ names, match the address
add an actionone file in that page's _methods/
add something every page has (a menu, a sidebar)covers and links on the _page.block.ts of the folder it wraps (Layouts)
say only some people see itfor: [Planner] on it (Layouts and access)
check a state (disabled button, error shown)Page.read.x.is on the page, or an Expect Block in _expect/, in a step's expect (Checks)
say what a page showsits read (What a page shows)
sign in as someonean account in src/accounts/, then map({ as: Planner }) (Flows)
string steps togethera file in src/flows/<page>/, named for its outcome (Flows)
give a flow dataa mem key, with its fake value if it wants one, in src/states/*.mem-keys.ts (Data)
run a feature's flowsa label in the config, then waygraph test --label <it> (Testing)
see all of itwaygraph studio (Waygraph Studio)
keep folders honestwaygraph map
reuse a tool's pages in another projectwaygraph map pack <group> (The Map)

Pointing it at your real app ​

  1. Set baseUrl in config/waygraph.config.ts (or BASE_URL in .env).
  2. Change each _page.block.ts's url to the real path.
  3. Rename (main)/(app_base)/'s folders to match your app's addresses.
  4. Run waygraph map: it lists every folder that doesn't match.

A new machine, a new teammate ​

The config is the list of what the project needs on a machine. After npm install, one command sets it all up:

sh
npm install
npx waygraph install
From the configwaygraph install
alwaysChromium, with the project's own Playwright (the version its tests run)
playwright.use.browserName, playwright.projectseach browser they name
extensionsthe browser extensions, into waygraph's cache
demo.voicethe voice's model (kokoroVoice(): a Python environment and ~350 MB, once per machine)
what those readlisted in .env.example and .env, blank and commented (# OPENAI_API_KEY=)

What it can't install, it checks and names at the end (ffmpeg for a voice-over, a voice whose setup failed) and exits 1; the rest is still set up. It does only what's missing, so run it again whenever the config changes or after npm install waygraph@latest; --update fetches everything again, and --with-deps also installs the browsers' system packages (Linux CI). Downloads are shared by every project on the machine (~/.cache/waygraph, ~/.cache/ms-playwright), and installing one project's browsers never removes another's.

Keeping it up to date ​

sh
npm install waygraph@latest
npx waygraph install                                  # what the new version needs (a newer browser, voice model)
npx waygraph upgrade                                  # dry run: lists new and changed scaffold files
npx waygraph upgrade "src/map/(external)/hoppscotch" --apply
npx waygraph upgrade --skills                         # refresh .agents/skills
npx waygraph upgrade --codemod keys                   # rewrite code a release changed (see Deprecated)
npx waygraph upgrade --codemod lands                  # `Block as MethodBlock<A, B>` casts -> .method(Block, { lands: B })
npx waygraph upgrade --codemod ff                     # { ff: true } on step after step -> .ffStart() ... .ffEnd()
npx waygraph upgrade --codemod chain                  # drops .start() and .end(): the chain is the flow
npx waygraph upgrade --codemod pages                  # a flow's Block imports -> its pages' Page / Page.do.x
npx waygraph upgrade --codemod expect                 # Assert Blocks and .assert() steps -> Expect Blocks in each step's expect: [...]

upgrade copies only the paths you name, and replaces a file that differs only with --overwrite.

A freeform layout ​

A small project can skip src/map/: any *.block.ts anywhere under src/ is loaded, and a _layout.block.ts covers the pages in its folder the same way. Freeform gives up what the Map gives (waygraph map can't hold folders to addresses), so it's for trying things; moving to the Map later only moves files: migrating.

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