mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
## Summary Fixes #25869 Two fixes to enable `jest.useFakeTimers()` to work with `@testing-library/react` and `@testing-library/user-event`: - Set `setTimeout.clock = true` when fake timers are enabled. testing-library/react's `jestFakeTimersAreEnabled()` checks for this property to determine if `jest.advanceTimersByTime()` should be called when draining the microtask queue. Without this, testing-library never advances timers. - Make `advanceTimersByTime(0)` fire `setTimeout(fn, 0)` timers. `setTimeout(fn, 0)` is internally scheduled with a 1ms delay per HTML spec. Jest/testing-library expect `advanceTimersByTime(0)` to fire such "immediate" timers, but we were advancing by 0ms so they never fired. ## Test plan - [x] All 30 existing fake timer tests pass - [x] New regression test validates both fixes - [x] Original user-event reproduction now works (test completes instead of hanging) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>