Files
Codeman/test/mobile/helpers/server.ts
T
RandalixandClaude Opus 5.5 6f87186deb test(mobile): createTestServer() binds an ephemeral port (#440)
The helper cached servers by port, but every mobile file starts exactly one, so the cache was never shared: it is now a Set that stopAllTestServers() walks. PORTS leaves helpers/constants.ts, the nine tests set baseUrl after start(), and the README drops the port column and the pick-a-port step.

Committed without the pre-commit hook: accessibility, subagent-windows and visual-regression were not prettier-clean on master already; formatting them would bury the port lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 16:29:01 +02:00

24 lines
663 B
TypeScript

import { WebServer } from '../../../src/web/server.js';
const servers = new Set<WebServer>();
/** A test server on an ephemeral port; read the port from `server.boundPort` once this resolves. */
export async function createTestServer(): Promise<WebServer> {
const server = new WebServer(0, false, true); // testMode = true
await server.start();
servers.add(server);
return server;
}
export async function stopTestServer(server: WebServer): Promise<void> {
await server.stop();
servers.delete(server);
}
export async function stopAllTestServers(): Promise<void> {
for (const server of servers) {
await server.stop();
}
servers.clear();
}