mirror of
https://github.com/tester-army/e2e.git
synced 2026-11-27 02:36:21 +08:00
* docs: fix stale and wrong claims in guides - output: --artifacts -> --output in bug-bash guide and skill; sessions and cache locations follow output / cache.dir in security; artifact path gains the agent segment in github - ci: upload artifacts on !cancelled() in ci guide and skill - mcp: several sessions (--max-sessions) in security - replay cache naming: "Commit the replay cache" heading and anchors (old anchor kept, e2e init links the new one), trace replay -> replay cache in writing-an-engine and executors - timeouts: STEP_TIMEOUT / STEP_BUDGET_EXHAUSTED advice names config timeout, judgmentTimeout, maxSteps, maxModelCalls (debugging, skill) - mobile: app.open() in device examples and quickstart, mobileTools pack all mutating, Android toolbar anchor, drop agent-device release note - executors: verdict code rules, missing ctx members and scrollUntil, a replay cache section; agent-steps passed+code rule - migrate: swipe direction is the content's, `!` test exclusions, video row status, Kernel for Selenium Grid - secrets: an unset env string fails config load, a provider's value is redacted only from its first fill; three secret sinks - misc: Models link text, telemetry links outbound connections, integration config wording, web-only expect(web) in a cross-platform block, capabilities heading in engine reference, swipe direction in screen reference * docs(skill): separate the credential redaction paragraph * docs(reference): KERNEL_API_KEY names @e2e-dev/kernel
139 lines
4.9 KiB
Plaintext
139 lines
4.9 KiB
Plaintext
---
|
|
title: Coding agents
|
|
description: Give a coding agent the skill, a live app session, and reports it can use to write and debug tests.
|
|
---
|
|
|
|
`e2e init` installs a skill for writing and running tests, plus MCP
|
|
configuration for inspecting the app. Coding agents use the CLI to run
|
|
tests and the reports to investigate failures.
|
|
|
|
## The skill
|
|
|
|
```bash
|
|
npx e2e init
|
|
```
|
|
|
|
| Path | Used by |
|
|
| --- | --- |
|
|
| `.agents/skills/e2e/` | Agents that read `.agents/skills` |
|
|
| `.claude/skills/e2e/` | Claude Code; a symlink to `.agents/skills/e2e/` when both are installed |
|
|
|
|
The copy holds `SKILL.md` and topic references; the link is the layout
|
|
`npx skills add` produces, so one copy serves every agent. Run `init` again
|
|
after upgrading e2e to refresh it.
|
|
|
|
Without `init`, `npx skills add tester-army/e2e` installs the skill from the
|
|
repository, and `npx e2e guide [topic]` prints it from the
|
|
installed package.
|
|
|
|
For agents that need an explicit pointer, add this line to your project
|
|
instructions. `init` leaves those files unchanged:
|
|
|
|
```md title="AGENTS.md"
|
|
End-to-end tests use e2e; read .agents/skills/e2e/SKILL.md before writing or running one.
|
|
```
|
|
|
|
## How an agent looks at the app
|
|
|
|
`e2e mcp` lets the coding agent open and interact with the app. Each agent,
|
|
subagents included, opens its own session, so several can drive the app at
|
|
once. Its `locate` tool checks a `screen.*` locator against the current app and returns
|
|
the test code when exactly one element matches.
|
|
|
|
`init` registers the server in `.mcp.json` for Claude Code and
|
|
`.cursor/mcp.json` for Cursor. To register it with Claude Code by hand:
|
|
|
|
```bash
|
|
claude mcp add e2e -- npx e2e mcp
|
|
```
|
|
|
|
See the [MCP server reference](/reference/mcp) for its tools, session rules,
|
|
and flags. Run tests and read reports through the CLI.
|
|
|
|
## How an agent writes a test
|
|
|
|
The skill tells the coding agent to read the config and an existing test
|
|
first. It uses `agent.act` for one goal at a time and checks the outcome
|
|
with `expect`. Known fields and exact values can use `screen` directly:
|
|
|
|
```ts title="tests/checkout.e2e.ts"
|
|
import { test, expect, credentials } from 'e2e';
|
|
|
|
test('a signed-in user reaches checkout', async ({ screen, app, agent }) => {
|
|
const user = credentials.user('customer');
|
|
await app.open('/login');
|
|
await screen.getByLabel('Email').fill(user.username);
|
|
await screen.getByLabel('Password').fill(user.password);
|
|
await screen.getByRole('button', { name: 'Sign in' }).click();
|
|
await expect(screen.getByRole('heading', { name: 'Welcome back' })).toBeVisible();
|
|
|
|
await agent.act('Add the cheapest item on the page to the cart and open the cart');
|
|
await expect(screen.getByRole('heading', { name: 'Your cart' })).toBeVisible();
|
|
});
|
|
```
|
|
|
|
The main rules are:
|
|
|
|
- One `agent.act` per goal, followed by an `expect`. The assertion makes the
|
|
step's cache entry eligible for replay, and it is what fails when the agent
|
|
did the wrong thing.
|
|
- No sleeps. Locators poll, actions wait for their target, and `expect`
|
|
retries until its timeout.
|
|
- Secrets through `credentials.user(name)`, declared in the config, never
|
|
literal in a test.
|
|
|
|
## How an agent runs it
|
|
|
|
```bash
|
|
npx e2e run tests/checkout.e2e.ts
|
|
```
|
|
|
|
Run one file while iterating. For model configuration and credentials, see
|
|
[Models](/models). Fix CLI, config, and collection errors before
|
|
retrying a run.
|
|
|
|
## How an agent reads the result
|
|
|
|
Every run writes `.e2e/report.json`. For a report that is easier to read,
|
|
run:
|
|
|
|
```bash
|
|
npx e2e run tests/checkout.e2e.ts --reporter list,markdown
|
|
```
|
|
|
|
This writes `.e2e/summary.md` and a page for each failed or flaky test under
|
|
`.e2e/failures/`. Start with the failure page. It includes the failing line,
|
|
steps, recent model turns, and the screen at failure.
|
|
|
|
When reading JSON, check `run.errors` for run-level failures, then the last
|
|
attempt of each failed result. Its `error`, `steps`, and `artifacts` show
|
|
what failed and how far the test got. `--reporter json` also prints the JSON
|
|
report to stdout.
|
|
|
|
For model-call details, use `--ai-trace` and read the trace with
|
|
[unbox-ai](/debugging#agent-steps). Avoid opening the raw trace in an agent's
|
|
context; it repeats prompts and can be several megabytes.
|
|
|
|
## How an agent treats the cache
|
|
|
|
A verified `agent.act` can replay from `.e2e/cache/` on later runs. Use
|
|
`--no-cache` to check the live agent behavior after changing a test or to
|
|
investigate a replay failure. Pair it with `--ai-trace` to capture every
|
|
model call in the flow.
|
|
|
|
Do not edit recordings by hand. A failed read-write run removes implicated
|
|
entries so a later verified run can replace them. See
|
|
[Caching agent steps](/cache).
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="CLI reference" icon="terminal" href="/reference/cli">
|
|
init, guide, mcp, and run, flag by flag.
|
|
</Card>
|
|
<Card title="MCP server" icon="server" href="/reference/mcp">
|
|
Inspect the app before writing a test.
|
|
</Card>
|
|
<Card title="Debugging a run" icon="bug" href="/debugging">
|
|
The report, the artifacts, and the agent flags.
|
|
</Card>
|
|
</CardGroup>
|