fix: Explicitly bind web server to 127.0.0.1 in tests and prevent the development build process from running in the test environment.

This commit is contained in:
syntaxbullet
2026-01-31 14:30:44 +01:00
parent e252d6e00a
commit c2d67d7435
2 changed files with 4 additions and 3 deletions

View File

@@ -92,11 +92,12 @@ import { createWebServer } from "./server";
describe("Settings API", () => { describe("Settings API", () => {
let serverInstance: WebServerInstance; let serverInstance: WebServerInstance;
const PORT = 3009; const PORT = 3009;
const BASE_URL = `http://localhost:${PORT}`; const HOSTNAME = "127.0.0.1";
const BASE_URL = `http://${HOSTNAME}:${PORT}`;
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks(); jest.clearAllMocks();
serverInstance = await createWebServer({ port: PORT }); serverInstance = await createWebServer({ port: PORT, hostname: HOSTNAME });
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -37,7 +37,7 @@ export async function createWebServer(config: WebServerConfig = {}): Promise<Web
// Manage build process in development // Manage build process in development
let buildProcess: Subprocess | undefined; let buildProcess: Subprocess | undefined;
const isDev = process.env.NODE_ENV !== "production"; const isDev = process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test";
if (isDev) { if (isDev) {
logger.info("web", "Starting Web Bundler in Watch Mode..."); logger.info("web", "Starting Web Bundler in Watch Mode...");