feat!: the app is declared on its target; engines only drive it

Merged
OK
2mo ago
+2438-2880

The app under test is declared on its target, and nowhere else. Engines only drive it. This is the first half of #648: the app move and the runtime fixes, without defineService, which follows in #648 on top of this branch.

targets: [
  { name: 'chromium', engine: web(), app: { url: 'http://127.0.0.1:0', command: { executable: 'pnpm', args: ['dev', '--port', '{port}'] } } },
  { name: 'ios', engine: mobile({ platform: 'ios' }), app: { bundleId: 'dev.shop.app', appPath: './build/Shop.app', permissions: { camera: 'grant' } } },
],

The app on the target

  • target.app holds { url | bundleId, appPath, identity, environment, launchArguments, permissions, command, readyUrl }.
  • web({ url }), mobile({ app }), an app key directly on the target, and services anywhere are unknown keys: a plain break, no migration messages.
  • defineEngine gets validateApp: web() needs app.url, mobile() needs bundleId or appPath, and app.url on a mobile target fails as not supported yet with a platform-specific note. defineEngine({ app }) is an unknown key.
  • prepare and init receive the resolved app as info.app.
  • requires: ['browser' | 'native-app'] is derived from the target's app, not declared by engines.
  • Replay-cache and session keys are byte-identical to main, pinned by packages/e2e/tests/unit/target-identity.test.ts.

Services wait for the next release

  • There is no services key in this version; the docs carry a callout in place of the old services sections. Nothing in the repo used them.

Refused at load

  • a port-0 app.url with nothing to start on it
  • reuseExisting on a free port: what already answers cannot serve the port the run assigns

e2e mcp

  • A cancelled or disconnected open_session, or a server shutting down, aborts an open still starting its app command and stops what it started (CANCELLED).
  • A shared start that every waiting session gave up on is abandoned, and the next session starts it afresh.
flowchart LR
  T[target.app] --> C[checkTargetApp: shape]
  C --> V[engine.validateApp: what the platform needs]
  V --> R[resolveTargetApp: base URL, identity, command with port]
  R --> P[allocateAppPorts]
  P --> W[workers: assignPorts from the bootstrap]

Verified

Ran it locally: yes

  • Testbed, built CLI (pnpm test:testbed), its config declaring app: { url, command } on the target: target "web" command ready 88ms, 14 files, 70 tests passed, 1 skipped, the command stopped at the end.
  • packages/e2e/tests/unit/target-identity.test.ts pins the cache and session digests of the same apps declared the old way.