()
| 41 | }; |
| 42 | |
| 43 | export default async function setup(): Promise<(() => Promise<void>) | void> { |
| 44 | if (process.env.E2E_CLOUD_URL) { |
| 45 | await waitForHttp(process.env.E2E_CLOUD_URL); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | if (bootLogFile) mkdirSync(resolve(bootLogFile, ".."), { recursive: true }); |
| 50 | ensureE2eMcpSessionTimeoutEnv(); |
| 51 | |
| 52 | // Suite-owned trace store — every run captures distributed traces. Booted |
| 53 | // once outside the retry: it binds its own OS-assigned port (not a claimed |
| 54 | // one), so an EADDRINUSE on the claimed block doesn't implicate it. |
| 55 | const motel = await bootMotel(); |
| 56 | // Publish to the test workers (they inherit this process's env): scenarios |
| 57 | // that assert on exported spans yield the Telemetry service, which exists |
| 58 | // only when this is set. No motel → those scenarios skip, never fail. |
| 59 | if (motel) process.env.E2E_MOTEL_URL = motel.url; |
| 60 | |
| 61 | // Claim a free port block (preferred block first, walk forward past |
| 62 | // squatters/colliding checkouts), boot the stack, and retry on EADDRINUSE — |
| 63 | // on Linux CI an ephemeral outbound socket can still grab a claimed port |
| 64 | // between probe and bind, so re-claim the next block and retry. claimAndBoot |
| 65 | // publishes the claimed ports via env (E2E_*_PORT) so the test workers — |
| 66 | // spawned after this — derive the same URLs; the imported targets/cloud |
| 67 | // constants were computed BEFORE the claim, so use the claimed values here. |
| 68 | let booted; |
| 69 | try { |
| 70 | booted = await claimAndBoot( |
| 71 | [ |
| 72 | { envVar: "E2E_CLOUD_PORT", offset: 0, label: "cloud vite dev" }, |
| 73 | { envVar: "E2E_CLOUD_DB_PORT", offset: 1, label: "cloud dev-db (PGlite)" }, |
| 74 | { envVar: "E2E_WORKOS_EMULATOR_PORT", offset: 2, label: "WorkOS emulator" }, |
| 75 | { envVar: "E2E_AUTUMN_EMULATOR_PORT", offset: 3, label: "Autumn emulator" }, |
| 76 | ], |
| 77 | async (ports) => { |
| 78 | const publicUrl = `http://localhost:${ports.E2E_CLOUD_PORT!}`; |
| 79 | const cloud = await bootCloud({ |
| 80 | cloudPort: ports.E2E_CLOUD_PORT!, |
| 81 | dbPort: ports.E2E_CLOUD_DB_PORT!, |
| 82 | workosPort: ports.E2E_WORKOS_EMULATOR_PORT!, |
| 83 | autumnPort: ports.E2E_AUTUMN_EMULATOR_PORT!, |
| 84 | workosClientId: E2E_WORKOS_CLIENT_ID, |
| 85 | cookiePassword: E2E_COOKIE_PASSWORD, |
| 86 | publicUrl, |
| 87 | logFile: bootLogFile, |
| 88 | // Server + browser spans → the suite's motel. The app's exporter is |
| 89 | // endpoint-agnostic, so the same layer that ships prod traces to |
| 90 | // Axiom ships e2e traces to the suite store — "why was that page |
| 91 | // slow" gets a span waterfall, not a guess. |
| 92 | extraEnv: { ...motelExporterEnv(motel, publicUrl), ...optionalCloudEnv() }, |
| 93 | }); |
| 94 | return { teardown: cloud.teardown, value: cloud }; |
| 95 | }, |
| 96 | { label: "cloud" }, |
| 97 | ); |
| 98 | // Publish the Autumn emulator URL to the test workers (they inherit this |
| 99 | // process's env): scenarios that assert on tracked usage yield the Autumn |
| 100 | // service, which exists only when this is set. No emulator → those scenarios |
nothing calls this directly
no test coverage detected