Tests: Don't attempt to create echo server if internals is not exposed

This commit is contained in:
Tim Ledbetter 2024-12-31 23:23:57 +00:00 committed by Andreas Kling
parent 7f8ba951cb
commit a24718cc49
Notes: github-actions[bot] 2025-01-03 10:48:12 +00:00

View file

@ -121,7 +121,15 @@ class HTTPTestServer {
}
}
const __httpTestServer = new HTTPTestServer(`http://localhost:${internals.getEchoServerPort()}`);
const __httpTestServer = (function () {
if (globalThis.internals && globalThis.internals.getEchoServerPort)
return new HTTPTestServer(`http://localhost:${internals.getEchoServerPort()}`);
return null;
})();
function httpTestServer() {
if (!__httpTestServer)
throw new Error("window.internals must be exposed to use HTTPTestServer");
return __httpTestServer;
}