ruvnet/ruflo

Implement Comprehensive Test Cleanup Patterns from @mikkihugo's Analysis

Open

#120 ouverte le 5 juil. 2025

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)TypeScript (5 727 forks)batch import
enhancementgood first issue

Métriques du dépôt

Stars
 (51 130 stars)
Métriques de merge PR
 (Merge moyen 10h 49m) (56 PRs mergées en 30 j)

Description

Based on @mikkihugo's excellent test framework analysis in PR #44, we should implement better test cleanup patterns:\n\n## Issues Identified:\n- Pending promise errors in tests with background timers\n- Missing proper async cleanup in test teardown\n- Unhandled timers causing test runner warnings\n- Need for consistent test utilities\n\n## Proposed Solutions:\n\n### 1. Test Cleanup Utilities\njavascript\n// Standardized cleanup for all async operations\nclass TestCleanup {\n constructor() {\n this.timers = new Set();\n this.promises = new Set();\n }\n \n registerTimer(timer) { this.timers.add(timer); }\n registerPromise(promise) { this.promises.add(promise); }\n \n async cleanup() {\n // Clear all timers\n this.timers.forEach(timer => clearTimeout(timer));\n // Await all promises\n await Promise.allSettled([...this.promises]);\n }\n}\n\n\n### 2. Improved Test Structure\n- Before/after hooks that properly clean up resources\n- Timeout wrappers for all async operations\n- Consistent error handling patterns\n\n### 3. Performance Test Utils\nImplement the missing PerformanceTestUtils mentioned in the analysis\n\n## Benefits:\n- Eliminate flaky tests\n- Faster test execution\n- Better CI/CD reliability\n- Easier test debugging\n\n## Credit\nThis issue is based on the thorough test analysis by @mikkihugo in PR #44, particularly the test-status.md report.\n\n/cc @mikkihugo

Guide contributeur