fix(run): refuse test.skip() from an afterEach hook or a fixture teardown

AS
3h ago
+171-8

What and why

  • test.skip() called from an afterEach hook or a test.extend() fixture's teardown failed a passing test with ERROR: [object Object]. The teardown loops in run/execute.ts (e2e run) and run/standalone-test.ts (e2e mcp's close_session) handed the skip signal to the failure recorder without the isRuntimeSkip check the body path has, so the signal object was stringified.
  • Both catches now turn the signal into INVALID_ARGUMENT after a test that did not skip, worded like the late test.fail() refusal (lateSkipError in internal/skip.ts, sharing core's LATE_VERDICT). After a test that already skipped, a second skip in its teardown agrees with the verdict and does nothing, so a shared test.skip(flag) guard in beforeEach and afterEach keeps the test skipped. The MCP path carries the verdict to its later teardown.
  • Playwright instead honors a skip there: it marks a passed test skipped and ignores the call after a failure. Refusing it matches e2e's late test.fail(), and the Throws row says how it differs.
  • Docs: a Throws row under test.skip in reference/test.mdx, mirrored in the ja and zh pages.

Issue

Fixes #1896

Verified

Ran it locally: yes

The reproduction from the issue (skip-in-after-each) on the published packages and on this branch's build:

test.skip(true, 'too late') in afterEach after a passing bodyresult
e2e 0.23.1 (main)ERROR: [object Object]
this branchINVALID_ARGUMENT: test.skip() cannot skip a test from an afterEach hook or a fixture teardown: its verdict is already reached; call it in the test body or a beforeEach hook
  • tests/integration/runner-lifecycle.test.ts: a skip in a fixture teardown, a skip in afterEach after a passing body, and one after a failing body, where the refusal is a secondary error beside ASSERTION_FAILED. With main's catches it fails with "message": "[object Object]".
  • tests/integration/mcp-test-run.test.ts: close_session on a test whose afterEach skips reports Cleanup (afterEach): INVALID_ARGUMENT: …. With main's catches it reports Cleanup (afterEach): ERROR: [object Object].
  • A test that skips in beforeEach and again in afterEach stays skipped with its reason, under e2e run (runner-lifecycle.test.ts) and through close_session (mcp-test-run.test.ts).
  • The runner-lifecycle, MCP test-run, and expected-failure integration files (58 passed), the e2e unit suite (3911 passed), and pnpm check pass.

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/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.