chore(frontend): Max retries toevoegen

Frontend unittesten hoogstens 60 retries van 1 seconde
This commit is contained in:
Tibo De Peuter 2025-04-17 12:09:23 +02:00
parent 8c338d8d56
commit 93624cdc6a
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2

View file

@ -3,14 +3,14 @@ import { ChildProcess } from "node:child_process";
let backendProcess: ChildProcess; let backendProcess: ChildProcess;
async function waitForEndpoint(url: string, delay = 1000): Promise<void> { async function waitForEndpoint(url: string, delay = 1000, retries = 60): Promise<void> {
try { try {
await fetch(url); await fetch(url);
} catch { } catch {
// Endpoint is not ready yet // Endpoint is not ready yet
await new Promise((resolve) => setTimeout(resolve, delay)); await new Promise((resolve) => setTimeout(resolve, delay));
// Retry // Retry
await waitForEndpoint(url, delay); await waitForEndpoint(url, delay, retries - 1);
} }
} }