mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-11 01:39:41 +02:00
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>
24 lines
663 B
TypeScript
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();
|
|
}
|