docs(core): say where test.step records no step
Merged
LE
3d ago+17+17+01234567890123456789-6-6-0123456789
What
- The
test.step()doc comment and reference entry now say that in abeforeAllorafterAllhook, a worker fixture, or anopenHost()session,bodyjust runs, and no report gets a step fortitle. A call from work its phase left running (a body or hook past its timeout) isCANCELLED, and any other call outside these, such as one at collection, isCOLLECTION_ERROR.
Why
- The comment said reports show the title wherever the call is allowed, and "Outside a test the call is
COLLECTION_ERROR", which reads as if abeforeAllhook (not a test) throws. In factrunTestStepjust runs the body there (packages/core/src/internal/test-step.ts:30), and in a hosted session, whose attempt has no step recorder (test-step.ts:35). This was the cubic thread on #2381. - The prose entry on docs/reference/test.mdx already covered suite hooks, but not worker fixtures or
openHost().
How it works
- packages/core/src/types.ts:1149-1154: the closing paragraph of the
TestAPI.stepcomment. Since #2448 theTestAPIblock in docs/reference/test.mdx has no doc comments, so there is no mirrored copy. - docs/reference/test.mdx:401-405: the
test.stepbullet adds worker fixtures andopenHost()sessions, and the next bullet now limits theSTEP_NOT_AWAITEDfailure arounduse()to test-scoped fixtures. The Throws table gets aCANCELLEDrow (test.mdx:415, fromleftRunning()at test-step.ts:24-27), and theCOLLECTION_ERRORrow (test.mdx:416) namesopenHost()sessions. - .changeset/document-test-step-in-suite-hooks.md is a
@e2e-dev/corepatch.
Issue
Docs-only change, no issue.
Verified
Ran it locally: yes
pnpm checkpasses.pnpm testpasses except one timing test,host-libraries.test.ts"kills an ldd that outlives its time", which failed once under the full run and passes when rerun alone. This change touches no code.- I checked the hook and worker-fixture claim with a throwaway run (not committed) through the
runProjecthelper used by tests/integration/test-step.test.ts. A worker fixture, a test fixture and abeforeAllhook each calltest.step, and the test checks that all three bodies ran. It passes, and its report has only the test fixture's step:
status: passed
steps (kind "step"): [["Test fixture setup", "beforeEach", "passed"]]
- The hosted-session case is the existing unit test "just runs the body where the attempt records no steps" (packages/e2e/tests/unit/test-step.test.ts:384). The step tests still pass:
$ npx vitest run tests/integration/test-step.test.ts tests/unit/test-step.test.ts
Test Files 2 passed (2)
Tests 34 passed (34)
- The
CANCELLEDcase: two more throwawayrunProjectruns calltest.stepafter the phase timed out, once from a test body (timeout: 300, step at 700 ms) and once from abeforeEachhook. Both catch:
{"code":"CANCELLED","message":"test.step() was called after its test ended"}
use()insidetest.step: a throwawayrunProjectprobe shows the test passes for a worker fixture, and fails withSTEP_NOT_AWAITEDfor a test-scoped fixture.- No screenshot: only comment and reference text change.
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.
Summary by CodeRabbit
- Documentation
- Clarified that
test.step()calls in setup and teardown hooks, worker fixtures, andopenHost()sessions run but don’t appear in reports. - Documented that calls from work continuing after its phase ends are reported as
CANCELLED. Other out-of-scope calls, except those inopenHost()sessions, are reported asCOLLECTION_ERROR. - Noted that wrapping
use()in a test-scoped fixture fails withSTEP_NOT_AWAITED.
- Clarified that