/** * Test setup utilities */ // Base URL for local dev server export const BASE_URL = process.env.TEST_BASE_URL || "http://localhost:5173"; // Test configuration export const TEST_CONFIG = { timeout: 30000, retries: 0, }; /** * Wait for the server to be ready */ export async function waitForServer(maxAttempts = 30): Promise { for (let i = 0; i < maxAttempts; i++) { try { const res = await fetch(`${BASE_URL}/xrpc/cash.attoshi.getSupply`); if (res.ok) { return; } } catch { // Server not ready yet } await sleep(1000); } throw new Error(`Server not ready after ${maxAttempts} attempts at ${BASE_URL}`); } /** * Sleep for a given number of milliseconds */ export function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } /** * Check if the server is running */ export async function isServerRunning(): Promise { try { const res = await fetch(`${BASE_URL}/xrpc/cash.attoshi.getSupply`); return res.ok; } catch { return false; } }