fix(e2e): keep runner errors from a config-loaded engine classified

Merged
OK
2mo ago
+129-24

An engine loaded from e2e.config.ts comes from a second copy of the runner, so its TestError fails instanceof E2EError. translateEngineError only had the instanceof check, so it turned the engine's INVALID_LOCATOR (and any other runner code an engine throws) into an infrastructure ENGINE_FAILURE with exit 3. In-process runs were fine, which is why the in-process web-platform test never caught it.

  • isForeignE2EError becomes isE2EError (packages/e2e/src/internal/errors.ts), the one predicate for "runner error from any module copy". It matches local instances too, since they carry the same Symbol.for marker.
  • Every runner-error instanceof in packages/e2e/src that can see a foreign error now uses it: translateEngineError, translateProvisioningError, codedMessage, classifyError, config load, engine session normalize, expect.poll not-yet, agent phase codes, isModelUnreachable, toAgentError, and collection (isCollectionError, keyed on COLLECTION_ERROR).
  • Collection had the same bug: a test file collects in its own copy, so its CollectionError was reported as failed to collect <file>: ... instead of <file>: ....
  • classifyAttemptStatus drops instanceof TestTimeoutError; the TEST_TIMEOUT code check already covered it.
  • @e2e-dev/web and @e2e-dev/mobile already fall back to name checks for foreign errors, so they are unchanged.

Tests: tests/integration/foreign-engine-errors.test.ts runs through runProjectWithConfigFile and asserts the caught code, the reported code and category, and the collection message. A unit test pins translateEngineError. Mutation-checked: reverting either translateEngineError or isCollectionError fails them.

Follow-up: oskar/tests-integration loosened the *css= case in web-platform.test.ts to assert the message because of this bug. Once both land it can assert INVALID_LOCATOR again, like the in-process version on main does.

Verified

Ran it locally: yes

  • testbed, built CLI, a scratch test running browser.locator('*css=ul[aria-label="Todo column"] >> li').count() on /board: node node_modules/e2e/dist/cli/bin.js run tests/zz-foreign-errors.e2e.ts
mainthis branch
ENGINE_FAILURE: a selector that captures with * (*css=article >> text=Hello) is not supported: use filter({ has }) instead, exit 3INVALID_LOCATOR: a selector that captures with * (*css=article >> text=Hello) is not supported: use filter({ has }) instead, exit 1
  • New integration test fails on main (both INVALID_LOCATOR cases get ENGINE_FAILURE) and passes here.