// apps/miniprogram/e2e/check-readiness.ts async function check(url: string, label: string) { for (let i = 0; i < 5; i++) { try { const res = await fetch(url); if (res.ok) return; } catch { /* retry */ } console.log(`⏳ ${label} 未就绪 (${i + 1}/5)...`); await new Promise((r) => setTimeout(r, 2000)); } throw new Error(`❌ ${label} 未就绪: ${url}`); } export default async function setup() { const apiBase = process.env.E2E_API_URL || 'http://localhost:3000'; await check(`${apiBase}/api/v1/health`, '后端 API'); console.log('✅ 小程序 E2E 环境就绪'); }