Skip to content

fix(tests): prevent flaky dismiss in PointerEvent timestamp test#63

Merged
mironovsergey merged 2 commits into
mainfrom
fix/flaky-pointer-event-timestamp
May 26, 2026
Merged

fix(tests): prevent flaky dismiss in PointerEvent timestamp test#63
mironovsergey merged 2 commits into
mainfrom
fix/flaky-pointer-event-timestamp

Conversation

@mironovsergey

Copy link
Copy Markdown
Owner

Description

Fixes a flaky test in the Number options suite where the sheet was occasionally dismissed during a snap-back gesture.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Test update

Changes Made

  • Overrode timeStamp in the PointerEvent mock (jest.setup.js) to use performance.now() from Jest's faked clock instead of jsdom's internal real clock

Root Cause

The custom PointerEvent mock extends MouseEvent, whose constructor sets timeStamp via jsdom's own internal performance reference - bypassing Jest's faked clock. When two events are created in the same synchronous block, their real timestamps can differ by a few microseconds (e.g. dt = 0.001 ms). VelocityTracker then computes:

velocity = 30px / 0.001ms = 30,000,000 px/s

Far above the dismiss threshold → sheet closes when it should snap back. The failure was intermittent because it depended on CPU load at the moment of event construction.

Testing

  • New and existing unit tests pass locally (npm test)

@github-actions

Copy link
Copy Markdown

🎉 Thanks for opening your first pull request! We're excited to review your contribution to Bootstrap Sheet.

Please make sure:

  • Your code follows our contribution guidelines
  • All tests pass (npm test)
  • Your code is properly formatted (npm run format)
  • You've updated documentation if needed

A maintainer will review your PR as soon as possible. Feel free to ask questions if you need help!

@mironovsergey mironovsergey merged commit b46f093 into main May 26, 2026
17 of 29 checks passed
@mironovsergey mironovsergey deleted the fix/flaky-pointer-event-timestamp branch May 26, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant