-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Tests: Cleanup unnecessary jest timers setup #49030
Conversation
@@ -51,8 +51,6 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( { | |||
useDispatch: () => ( { saveEntityRecords: jest.fn() } ), | |||
} ) ); | |||
|
|||
jest.useRealTimers(); |
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.
None of those are necessary since we already default to using real timers.
@@ -8,7 +8,9 @@ import { render } from '@testing-library/react'; | |||
*/ | |||
import { AutosaveMonitor } from '../'; | |||
|
|||
jest.useFakeTimers( { legacyFakeTimers: true } ); | |||
jest.useFakeTimers(); |
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.
It wasn't necessary to use the legacy fake timers, so I removed that.
@@ -8,7 +8,9 @@ import { render } from '@testing-library/react'; | |||
*/ | |||
import { AutosaveMonitor } from '../'; | |||
|
|||
jest.useFakeTimers( { legacyFakeTimers: true } ); | |||
jest.useFakeTimers(); | |||
jest.spyOn( global, 'clearTimeout' ); |
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.
However, it was necessary to start spying on clearTimeout
and setTimeout
, as also displayed on the jest docs page.
It's odd that it worked before. I assume some cross-test-setup bleeding was going on.
Size Change: 0 B Total Size: 1.34 MB ℹ️ View Unchanged
|
Flaky tests detected in 4e31a36. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4405501538
|
What?
When opening #49029 I noticed that we still specifically enable real timers in a bunch of places, even though those are already the default timers. This PR cleans those up.
Why?
Just cleaning up.
How?
We're just removing a few unnecessary
jest.useRealTimers()
Testing Instructions
Verify all tests are still green.
Testing Instructions for Keyboard
None
Screenshots or screencast
None