/** Bound an actual fixture completion signal, not a count of event-loop * turns. Always clear the watchdog, and preserve real fixture failures. */ export async function completedWithin(completion: Promise, description: string, timeoutMs = 10_000): Promise { let timer: ReturnType | undefined; try { return await Promise.race([ completion, new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new Error(`Timed out after ${timeoutMs}ms waiting for ${description}`)), timeoutMs); }), ]); } finally { clearTimeout(timer); } }