Skip to content

Pressability test migrated to Jest moder timers#55410

Open
chicio wants to merge 3 commits intofacebook:mainfrom
chicio:pressability_jest_timers
Open

Pressability test migrated to Jest moder timers#55410
chicio wants to merge 3 commits intofacebook:mainfrom
chicio:pressability_jest_timers

Conversation

@chicio
Copy link
Contributor

@chicio chicio commented Feb 4, 2026

Summary:

This PR migrates the Pressability tests so that it uses Jest modern timers.
First, I centralized Fake timers setup in the beforeEach and restored in the afterEach (to run test in isolation with respect to timers).
I migrated all the calls previously used to fire all pending timers (jest.runOnlyPendingTimers) to jest.advanceTimersByTime, setting the correct timing need for the tests to verify the entire Pressability flows (including minimum press duration and long press delay configurations). This should improve the correctness of the tests (demonstrated also by the test plan below).
I also tried to increased the readability of the tests by extracting some constants (related to the inner configured delay/press duration of the Pressability class).

Changelog:

[GENERAL] [CHANGED] - Migrated Pressability tests to Jest modern timers

Test Plan:

  • Ran Pressability-test and verify all tests cases passed
  • Ran the full React Native test suite to ensure all tests pass.
  • Verified test correctness by intentionally breaking production code:
    • Modified callback invocation logic (onPressIn, onPressOut, onLongPress) to verify that tests were failing
    • Changed timing constants (eg. DEFAULT_MIN_PRESS_DURATION, DEFAULT_LONG_PRESS_DELAY_MS`)to verify that tests correctly failed

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 4, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants