this repo has no description
1/**
2 * Test setup utilities
3 */
4
5// Base URL for local dev server
6export const BASE_URL = process.env.TEST_BASE_URL || "http://localhost:5173";
7
8// Test configuration
9export const TEST_CONFIG = {
10 timeout: 30000,
11 retries: 0,
12};
13
14/**
15 * Wait for the server to be ready
16 */
17export async function waitForServer(maxAttempts = 30): Promise<void> {
18 for (let i = 0; i < maxAttempts; i++) {
19 try {
20 const res = await fetch(`${BASE_URL}/xrpc/cash.attoshi.getSupply`);
21 if (res.ok) {
22 return;
23 }
24 } catch {
25 // Server not ready yet
26 }
27 await sleep(1000);
28 }
29 throw new Error(`Server not ready after ${maxAttempts} attempts at ${BASE_URL}`);
30}
31
32/**
33 * Sleep for a given number of milliseconds
34 */
35export function sleep(ms: number): Promise<void> {
36 return new Promise((resolve) => setTimeout(resolve, ms));
37}
38
39/**
40 * Check if the server is running
41 */
42export async function isServerRunning(): Promise<boolean> {
43 try {
44 const res = await fetch(`${BASE_URL}/xrpc/cash.attoshi.getSupply`);
45 return res.ok;
46 } catch {
47 return false;
48 }
49}