Skip to content

Quick start ​

Pick a way in ​

Way inCommandWrites to your folder?
watch a checkout on saucedemo.com, step by stepnpx waygraph try demono
pick Blocks by hand on itnpx waygraph try auto (try auto:cli in the terminal)no
a new projectnpx waygraph init my-appyes
the full Sauce Demo examplebelowyes

Needs Node 24+ and @playwright/test 1.40+ (a peer dependency: you bring your own).

A new project ​

sh
npx waygraph init my-app
cd my-app
npm install
npx waygraph install     # what the config requires on this machine: the browser, and anything else it names
npm test                 # passes offline straight away
npx waygraph studio          # its map, flows and runs in the browser (beta)

Then:

TryCommand
watch a flow, step by stepnpm run demo
the same, by itselfnpm run demo:auto-next
play every flow as a testnpx waygraph test --flows
pick Blocks by handnpm run auto (npm run auto:cli in the terminal)
list the flowsnpm run list
lint Blocks and foldersnpm run check
Playwright's UInpm run test:ui

What each file is for: Your project.

Your first Block and flow ​

ts
import { Engine, MemPage, keys, checkpoint, defineNavBlock, defineMethodBlock, Trait } from "waygraph";

const LoginForm = checkpoint("LoginForm");
type LoginForm = typeof LoginForm;
const InventoryPage = checkpoint("InventoryPage");
type InventoryPage = typeof InventoryPage;

const LoginKeys = keys("login")<{ username: string }>();

const NavLogin = defineNavBlock({
  name: "nav-login",
  checkpoint: LoginForm,
  url: "https://example.com/login",
});

const SubmitLogin = defineMethodBlock({
  name: "submit-login",
  from: LoginForm,
  to: InventoryPage,
  requires: [LoginKeys.username],
  async act(page, _input, mem) {
    await page.getByLabel("Username").fill(mem.get(LoginKeys.username));
    await page.getByRole("button", { name: "Sign in" }).click();
  },
  verify: [Trait.url({ pathname: "/dashboard" })],
});

const mem = new MemPage();
mem.set(LoginKeys.username, "alice");

const flow = new Engine({ headless: true }).map().gotoPage(NavLogin).method(SubmitLogin);
await flow.run(mem);                    // inside a Playwright test: await flow.run(context, mem)

In a project the pieces go in their own files (src/states/, the page folder, src/flows/), and the flow imports engine from config/waygraph.config.ts. How it works explains each part.

The Sauce Demo example ​

examples/saucedemo is a complete project against saucedemo.com: live tests, demos, accounts, reads. It uses the waygraph checkout it lives in, so build that first:

sh
git clone https://github.com/deviate-dv8/waygraph.git
cd waygraph
npm install && npm run build
cd examples/saucedemo
npm install
npx waygraph install     # the browser, and the demo's voice (Kokoro, ~350 MB; it says if it can't)
npm test                 # 15 tests against the live site
npm run demo             # sign in, then shop
npm run auto             # pick Blocks by hand

Changed waygraph's source? npm run build at the root again; the example picks it up. A tour of its folders: Sauce Demo walkthrough.

Next ​

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