feat(skill): prefer agent.act when configured, tighten test structure and migration guidance
What
The e2e skills, the MCP server's test_lines tool, and the test-writing docs pages change in five ways:
- Trim
skills/e2e/SKILL.mdto 146 lines (9.1 KB, down 49% from 17.8 KB onmain) as a progressive-disclosure router that directs coding agents to load only the matching reference topic and jump via## Contents, movingRerunning a test while you fix itandFeedbackintoreferences/debugging.md. - Default UI user flows to
agent.act(with data inparams, one goal per test) whenevere2e.config.tsconfigures a model or custom executor onagents.defaultor a selectedagents.<name>, reservingscreen.*actions for low-level mechanics under test,test.setupsign-in, or model-less configs. - Steer coding agents to reuse existing
tests/, fixtures, helpers, and page objects; test one behavior per test with everyexpectandagent.assertat the end (no mid-test assertions, no stashed one-shot locator reads, no undone actions or unchecked screens); name repeated locators; own server data and cleanup intest.extendfixtures (try/finally); and in list mutations, add two items, act on the second item shown, never the first, and check the first is unchanged. - Harden
skills/migrate-to-e2e/SKILL.mdto preserve every source assertion at its original observation point, route same-platform targets with{ tags }and--targetinstead ofbeforeEachviewport or timezone skips, classifystaysper test (keeping tried-and-failed ports asblocked), and keep the resume headers inMIGRATION.md. - Update
test_linesine2e mcpto adapt its guidance across fresh drafts, resumed tests opened withopen_session { test }, and held tests attached withopen_session { attach }, includingagent.actadvice in fresh drafts only when the session's agent has a model or custom executor configured.
Why
Three failure modes showed up in real agent runs and migration evaluations:
SKILL.mdloaded 17.8 KB upfront on every invocation, and agents following the old skill wrote multi-behavior tests with mid-test assertions, test-body cleanup, repeated locators, and list mutations targeting row 1 (which pass broken apps that always edit or delete the first row).- When a project configured an agent model alongside an existing deterministic login test, smaller coding agents kept writing
screen.*action chains instead ofagent.act(0 of 17 tests on Claude Haiku 5.5 onmain). - On a real Playwright migration (HomeKeeper, 33 tests across 15 files), strict numeric assertion floors clashed with the no-mid-test-assertions rule, causing moved pre-reload checks, stashed one-shot reads, runtime
beforeEachtarget skips that ran fixture teardowns on skipped attempts, and blanket file-levelstayslabels.
How it works
skills/e2e/SKILL.md(146 lines, 9,113 bytes, down from 312 lines, 17,825 bytes onmain) keeps the compact frontmatter description, the 8-topic routing table, a 6-step workflow with an explicit pre-run audit (SKILL.md:69:agent.actdefault when configured, one behavior with no undone actions or unchecked screens, second item shown atSKILL.md:82, no mid-test assertions, every test passes alone), and compact core rules (SKILL.md:101).Rerunning a test while you fix itandFeedback(keeping its "Never file the issue yourself" and search-first guardrails) live inskills/e2e/references/debugging.md. The duplicateddocs/examples/skill/e2e.config.tsis removed becausedocs/examples/skill/e2e.setup.config.tscompiles the same config insetup.md.skills/e2e/references/writing-tests.mdopens## Contentsby directing agents to read "A complete file" and "Structure" first and load later API sections only when needed.## Structure(writing-tests.md:78) breaks Assert into sub-bullets covering mid-way.waitFor()narrowing, zero-match vs. multi-match locator exceptions, and banning pre-reload assertion moves or stashed one-shot reads (isVisible(),isEnabled(),count(),inputValue(),textContent(),getAttribute(),browser.evaluate()). It adds "Prove the change on the changed record" (writing-tests.md:129), "Act on the second item shown, never the first" (writing-tests.md:136), "Each test owns its starting state and passes alone" (writing-tests.md:174, noting simulator-onlyapp.clearState()on iOS anddevice.installAppon physical iPhones), "Name and reuse what the tests repeat" (writing-tests.md:194), and "Preferagent.actwhen a model is configured" (writing-tests.md:202), and warns under Fixtures thattest.extendteardowns still run afterbeforeEachcallstest.skip(...).projectTest(writing-tests.md:740anddocs/examples/skill/project-settings.e2e.ts) usesrequest,browser.cookies(url),randomUUID(), andagent.act, captures any returned project ID from a 2xx response before asserting HTTP201, wraps creation anduse()intry/finally, and checks delete status against[200, 204, 404].writing-tests.md:732keeps the web-only qualifier for namedsession(devices have no named sessions), andsetup.mdnotes settingworkers: 1only for shared state no test can own.skills/migrate-to-e2e/SKILL.mdupdates Step 5 (migrate-to-e2e/SKILL.md:225,:255,:267), Step 6, and Step 8 to preserve each source assertion at its original observation point without stashed one-shot reads or duplicateexpectpadding, route same-platform targets with{ tags }and--target, classifystaysper test (separatingblockedfromstays), and keep the resume header fields inMIGRATION.md.test_lines(packages/e2e/src/session-tools/test-lines.ts:204and:222):tool()anddraft()distinguish fresh recordings (testRan === undefined && attached !== true), resumed tests (testRan !== undefined), and held-test attachments (attached === true), wired throughpackages/e2e/src/session-tools/catalog.ts:81frompackages/e2e/src/mcp/session.ts:476(hasAgent: config.agent.model !== undefined || config.agent.executor !== undefined) andpackages/e2e/src/run/worker/held-test-tools.ts:462(attached: true). Fresh drafts includeagent.actguidance only whenhasAgentis true.tests/unit/mcp-test-lines.test.ts,tests/integration/mcp-test-run.test.ts, andtests/integration/mcp-step-attachment.test.tscover all three modes and both halves ofhasAgent.- The
agent,bug-bash,debugging, andmcpreferences and the docs pagesagentic-vs-deterministic,agent-steps,ci,coding-agents,core-concepts,core,mcp-server,quickstart,reference/expect,reference/mcp, andreference/screenfollow the same rules.docs/coding-agents.mdx's shop filter example waits for an over-$20 item in arrange and checks both the status text and visibleProductsitems;docs/core.mdx's chat example passesapp.baseUrltolaunch(web(), ...). Four standalone examples (docs/examples/skill/todos.e2e.ts,docs/examples/skill/project-settings.e2e.ts,docs/examples/skill/shop.e2e.ts, anddocs/examples/core/chat.e2e.ts) are registered inscripts/check-docs-examples.ts. plugins/e2e/skills/is regenerated bypnpm plugins:sync;.changeset/skill-test-names-and-mix.mdrecords apatchfore2e.
Verified
Ran it locally: yes, on head d9a3d64e4.
pnpm check -> exit 0 (55 verbatim docs examples compiled, 23 plugin files synced, 379 MDX pages)
e2e focused unit + MCP suites -> Test Files 9 passed (9), Tests 315 passed (315)
pnpm --filter @e2e-dev/testbed test (87f316cae, same runtime) -> Test Files 49 passed (49), Tests 619 passed | 1 skipped (620)
docs_impact.py (origin/main..87f316cae) -> 0 FAIL, 0 WARN, 0 INFO
mutant.sh (f290b8577, same src logic) -> 7 mutants, 7 killed, 0 survived, 0 unconfirmed, 0 did not build
- Mutation testing ran in a detached worktree at
f290b8577(identical branching logic intest-lines.ts,catalog.ts,session.ts, andheld-test-tools.ts;d9a3d64e4only updated comments intest-lines.tsand docs/skill text) againstmcp-test-lines.test.ts,mcp-test-run.test.ts, andmcp-step-attachment.test.ts, killing 7 of 7 mutants byAssertionError.
Agentic default and reuse A/B eval (web bookshop with agents.default.model + seeded support/shop.ts and deterministic login.e2e.ts)
Fresh delegated writers (Claude Haiku 5.5 and GPT-6 Luna, n=2 per arm) wrote cart, checkout, account, and auth suites under an identical neutral prompt, verified with tsc --noEmit and e2e list:
| Model | Arm | tsc & e2e list | New tests using agent.act | agent.act calls with params | screen.* action calls | Reused support/shop.ts | Mid-test expect |
|---|---|---|---|---|---|---|---|
| Haiku 5.5 | main (1642ef238) | pass | 0 / 17 (0%) | 0 / 0 | 39 | 10 / 10 | 1 |
| Haiku 5.5 | PR #2157 | pass | 18 / 18 (100%) | 25 / 32 (78%) | 0 | 10 / 10 | 0 |
| GPT-6 Luna | main (1642ef238) | pass | 13 / 16 (81%) | 2 / 22 (9%) | 15 | 8 / 8 (0/2 BOOKS) | 0 |
| GPT-6 Luna | PR #2157 | pass | 16 / 16 (100%) | 25 / 31 (81%) | 0 | 8 / 8 (2/2 BOOKS) | 0 |
Deterministic mutation evals (15-mutant web bookshop, no model configured)
Fresh delegated writers on the model-less bookshop (M3 = Remove deletes the first row; 3x clean, 15 mutants, every test run alone):
| Model | main (5acb82235, 17.8 KB) | Compressed PR (432c350ab, n=3) | Post-agent.act-default spot-check (n=1) |
|---|---|---|---|
| Haiku 5.5 | 13.3/15, M3 0 of 3 | 14.67/15 (15, 15, 14), M3 3/3, alone 58/58 | 14/15, M3 YES, alone 19/19, 0 agent.* |
| GPT-6 Luna | 12.7/15, M3 0 of 3 | 14.00/15 (15, 14, 13), M3 3/3, alone 46/46 | 10/15, M3 YES, alone 12/12, 0 agent.* |
Playwright migration eval on HomeKeeper (live local Supabase + Vite + Chromium/WebKit, 33 source tests across 15 files)
Fresh gpt-6-luna (high) migrations before and after the writing-tests.md and migrate-to-e2e/SKILL.md parity, target-routing, and per-test stays fixes, independently run live and audited by three stronger read-only advisors (Claude Fable 5.2, GPT-6.2 Astra, Gemini 4 Neon):
| Metric | Round 1 (before migration fixes) | Round 2 (after migration fixes) |
|---|---|---|
| Playwright tests ported | 11 / 33 (33%) across 5 files -> 14 e2e tests | 26 / 33 (79%) across 13 files -> 45 e2e tests |
Runtime beforeEach skips | 28 skipped attempts (25.1 s of 46.6 s run) | 0 skipped attempts (disjoint target runs) |
stays tests | 22 / 33 (blanket whole-file stays) | 7 / 33 (per-test classification) |
| Independent live run | 17 passed, 28 skipped, 0 failed | 45 / 45 passed, 0 skipped, 0 failed (Playwright untouched: 33/15) |
Round 2's three-advisor audit caught one remaining wording loophole (narrow isEnabled()/browser.evaluate() wording allowed stashing .isVisible()/.count()/.textContent()/.inputValue() one-shot reads); 87f316cae closed that loophole across the full read family, and d9a3d64e4 addresses all review comments from kdy1.
- Limits: No live LLM API key was configured locally, so the Bookshelf agentic A/B eval proved authoring,
tsc --noEmit, ande2e list, not liveagent.actexecution. Docs pages are verified bypnpm check(docs:check, 55 compiled verbatim examples, 379 MDX pages), not rendered screenshots.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.