04 / Flows
End-to-end tests written as goals, replayed exactly
Write the goal, not the selectors. A model drives a real browser to reach it, exact assertions check the result, and every step that passes is recorded. CI replays the recording deterministically, with no model call; when the app changes, the new recording is proposed for review, never applied silently.
import { flow } from "@bareci/flows";
flow("a buyer checks out with a saved card", async ({ page, ai, expect }) => {
await page.goto("/cart");
await ai.do("pay with the saved Visa and confirm the order");
await ai.check("an order confirmation number is shown");
await expect(page.getByRole("heading", { name: /thank you/i })).toBeVisible();
}); How it works
Goals in plain language
ai.do reaches a goal and ai.check decides whether a condition holds. The model reads the accessibility tree first and asks for a screenshot only when the tree is not enough.
Record, then replay
Recordings live in .bareci/flows/ in your repository. Strict mode in CI replays them and fails with a clear diff when the page no longer matches, instead of calling a model.
Healing is a proposal
When a replay drifts, a new recording is written as a patch that git apply accepts. A person or an agent accepts it; nothing changes a test without review.
Agents write flows live
Over MCP an agent gets a live browser: it sees the page, acts, and gets back the flow line that repeats each action. Writing a flow becomes a conversation.
Later Firefox and WebKit in CI images, video and traces stored with each run, and mobile apps on simulators are planned.
At a glance
| Browser | Chromium through Playwright |
|---|---|
| Modes | auto, strict (CI) and record |
| Model | Claude by default; bring your own key |
| Evidence | A screenshot per AI step, a JSON report and JUnit |
Questions
Does CI call a model on every run?
No. In strict mode, CI only replays recorded actions. A step with no recording, or one that no longer matches the app, fails with a diff and never calls a model.
Whose model key is used?
BareCI holds a key per organisation by default, and any repository can bring its own. Model calls are logged per step with their token counts and count against a separate model budget.
Can I mix Flows with ordinary Playwright code?
Yes. page is a Playwright page and expect is Playwright's, so AI steps and plain Playwright lines sit in the same flow.