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
parent 37f1e09631
commit baf654fbc4

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;
}