Skip to content

VirtualizedList: More Resilient Unit Tests#48819

Closed
yungsters wants to merge 1 commit into
facebook:mainfrom
yungsters:export-D68449850
Closed

VirtualizedList: More Resilient Unit Tests#48819
yungsters wants to merge 1 commit into
facebook:mainfrom
yungsters:export-D68449850

Conversation

@yungsters
Copy link
Copy Markdown
Contributor

Summary:
Currently, VirtualizedList-test.js has a subtle dependency on how asynchronous operations are queued. Specifically, it depends on...

  • Batchinator to use setTimeout for...
  • InteractionManager to use setImmediate for...
  • InteractionManager to resolve a promise via microtask.

As a consequence, any changes to this queueing logic (e.g. eliminating the unnecessary setImmediate and microtask) unnecessarily breaks these unit tests.

This changes the Jest unit tests to instead use jest. advanceTimersToNextTimer(<step>) instead of jest.runOnlyPendingTimers() so that the unit tests are no longer dependent on these specific queueing logic.

Changelog:
[Internal]

Differential Revision: D68449850

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jan 21, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D68449850

Summary:

Currently, `VirtualizedList-test.js` has a subtle dependency on how asynchronous operations are queued. Specifically, it depends on...

- `Batchinator` to use `setTimeout` for...
- `InteractionManager` to use `setImmediate` for...
- `InteractionManager` to resolve a promise via microtask.

As a consequence, any changes to this queueing logic (e.g. eliminating the unnecessary `setImmediate` and microtask) unnecessarily breaks these unit tests.

This changes the Jest unit tests to instead use `jest. advanceTimersToNextTimer(<step>)` instead of `jest.runOnlyPendingTimers()` so that the unit tests are no longer dependent on these specific queueing logic.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D68449850
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D68449850

yungsters added a commit to yungsters/react-native that referenced this pull request Jan 21, 2025
Summary:

Currently, `VirtualizedList-test.js` has a subtle dependency on how asynchronous operations are queued. Specifically, it depends on...

- `Batchinator` to use `setTimeout` for...
- `InteractionManager` to use `setImmediate` for...
- `InteractionManager` to resolve a promise via microtask.

As a consequence, any changes to this queueing logic (e.g. eliminating the unnecessary `setImmediate` and microtask) unnecessarily breaks these unit tests.

This changes the Jest unit tests to instead use `jest. advanceTimersToNextTimer(<step>)` instead of `jest.runOnlyPendingTimers()` so that the unit tests are no longer dependent on these specific queueing logic.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D68449850
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 22, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 0ead7de.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @yungsters in 0ead7de

When will my fix make it into a release? | How to file a pick request?

@yungsters yungsters deleted the export-D68449850 branch March 13, 2025 16:09
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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants