fix(run): refuse test.skip() from an afterEach hook or a fixture teardown
AS
3h ago+171+171+012345678901234567890123456789-8-8-0123456789
What and why
test.skip()called from anafterEachhook or atest.extend()fixture's teardown failed a passing test withERROR: [object Object]. The teardown loops inrun/execute.ts(e2e run) andrun/standalone-test.ts(e2e mcp'sclose_session) handed the skip signal to the failure recorder without theisRuntimeSkipcheck the body path has, so the signal object was stringified.- Both catches now turn the signal into
INVALID_ARGUMENTafter a test that did not skip, worded like the latetest.fail()refusal (lateSkipErrorininternal/skip.ts, sharing core'sLATE_VERDICT). After a test that already skipped, a second skip in its teardown agrees with the verdict and does nothing, so a sharedtest.skip(flag)guard inbeforeEachandafterEachkeeps the testskipped. 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.skipinreference/test.mdx, mirrored in thejaandzhpages.
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 body | result |
|---|---|
| e2e 0.23.1 (main) | ERROR: [object Object] |
| this branch | INVALID_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 inafterEachafter a passing body, and one after a failing body, where the refusal is a secondary error besideASSERTION_FAILED. With main's catches it fails with"message": "[object Object]".tests/integration/mcp-test-run.test.ts:close_sessionon a test whoseafterEachskips reportsCleanup (afterEach): INVALID_ARGUMENT: …. With main's catches it reportsCleanup (afterEach): ERROR: [object Object].- A test that skips in
beforeEachand again inafterEachstaysskippedwith its reason, undere2e run(runner-lifecycle.test.ts) and throughclose_session(mcp-test-run.test.ts). - The runner-lifecycle, MCP test-run, and expected-failure integration files (58 passed), the
e2eunit suite (3911 passed), andpnpm checkpass.
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.