ruvnet/ruflo

Implement Comprehensive Test Cleanup Patterns from @mikkihugo's Analysis

Open

#120 aberto em 5 de jul. de 2025

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (5.727 forks)batch import
enhancementgood first issue

Métricas do repositório

Stars
 (51.130 stars)
Métricas de merge de PR
 (Mesclagem média 10h 49m) (56 fundiu PRs em 30d)

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

Guia do colaborador