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