-
Notifications
You must be signed in to change notification settings - Fork 510
test: Improve debounce/throttle test performance by replacing real timers with fake timers #1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- After migating to fake timer, test time reduced from 4.08s to 1.16s - Test logic is not changed
- After migating to fake timer, test time reduced from 5.08s to 2.02s - Test logic is not changed
- After migating to fake timer, test time reduced from 903ms to 12ms - Test logic is not changed
- After migating to fake timer, test time reduced from 1450ms to 15ms - Test logic is not changed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1359 +/- ##
=======================================
Coverage 99.97% 99.97%
=======================================
Files 468 468
Lines 4459 4459
Branches 1313 1313
=======================================
Hits 4458 4458
Misses 1 1 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Summary
Replaced real timer usage with fake timers in debounce and throttle tests to eliminate flaky test risks and significantly improve test execution time.
Problem
delay()function, making them slow and potentially flakySolution
delay()calls withvi.advanceTimersByTime()for precise time controldelay()replacement, maintained original tests usingvi.useRealTimers()to avoid breaking existing functionalityPerformance Improvements
Individual Test Files
Overall Test Suite Impact
Test execution time: 19.64s → 11.33s (42.3% improvement)
Benefits