# Helpers — flows & mocks

> For the complete documentation index, see [llms.txt](/llms.txt)

Helpers are ordinary JS functions in `unotest/e2e/_helpers/`. There are two
kinds, and keeping them separate keeps scenarios clean.

## Flows — replay a UI journey

`flow_*` functions wrap a repeated user journey: sign-in, checkout, onboarding.
Write once, call from any scenario.

```js
// _helpers/flows.js
function flow_signin(email, password) {
  goto("/login");
  fill(getByLabel("Email"), email);
  fill(getByLabel("Password"), password);
  click(getByRole("button", { name: "Sign in" }));
}
```

An agent can also replay a flow live (`explore_run_flow`) to seed state, then
record a new test on top of it.

## Mocks — seed & reset data

Use the sandbox helpers to put the app into a known state before a test and clean
up after. Connection details are pinned in [config](/reference/config/) — a
scenario can't redirect them.

```js
// _helpers/mocks.js
function seed_cart(userId) {
  dbExec("INSERT INTO carts (uid) VALUES ($1)", userId);
  apiCall("POST", "/test/checkout/reset");
}
```

| Helper | Use |
| --- | --- |
| `dbQuery` / `dbExec` | parameterized SQL (postgres / mysql / sqlite) |
| `apiCall` | relative-path HTTP against `apiBaseUrl` |
| `shell` | run a binary (execFile, no shell interpretation) |

:::tip[Keep project knowledge in helpers]
The core stays project-agnostic. Anything specific to *your* app — seed scripts,
fixtures, endpoints — lives in `_helpers/`, never in the tool.
:::
