fix: guard auto-start server to only run when executed directly, not when imported by tests

This commit is contained in:
2026-08-12 21:30:35 +08:00
parent 452581c3b5
commit 9ec6c9add3
+4 -1
View File
@@ -32,6 +32,9 @@ export function startServer(port: number, browserManager?: BrowserManager): Prom
});
}
// Direct start when running as script
// Direct start when running as script (not when imported in tests)
// When imported by other modules, the caller is responsible for calling startServer()
if (process.argv[1] && (process.argv[1].endsWith('server.js') || process.argv[1].endsWith('server.ts'))) {
const port = parseInt(process.env.VISIONL_PORT || '9527', 10);
startServer(port);
}