← 教程列表
news

Core Pattern

📅 2026/6/12 16:30:02⏱ 约 5 分钟阅读👁 9 阅读

```typescript // ❌ BEFORE: Guessing at timing await new Promise(r => setTimeout(r, 50)); const result = getResult(); expect(result).toBeDefined(); // ✅ AFTER: Waiting for condition await waitFor(() => getResult() !== undefined); const result = getResult(); expect(result).toBeDefined(); ```

← 返回教程列表 AI8899 · 内容仅供学习参考