-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
core-data: Refactor tests to use real timers #47218
Conversation
Size Change: 0 B Total Size: 1.33 MB ℹ️ View Unchanged
|
Flaky tests detected in 0301419. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3939561718
|
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.
Thank you, @tyxla!
What?
This PR updates more tests in the
@wordpress/core-data
package to use real timers. This is a follow-up to #46714, #47056, and #47144.Why?
We discovered that Jest real timers are preferable when their use is possible, see facebook/react#25889 and the description in #46714.
This post is great writing that explains the rationale in more detail:
https://jsnajdr.wordpress.com/2023/01/11/prefer-jest-real-timers-when-testing-with-react-testing-library/
How?
We're removing the specific
jest.useFakeTimers();
calls. We're also removing the now unnecessaryjest.advanceTimersByTime()
calls and post-test cleanup that we've been doing withjest.runOnlyPendingTimers()
andjest.useRealTimers()
.Testing Instructions
Verify all tests still pass.
Testing Instructions for Keyboard
None
Screenshots or screencast
None.