Jest config: use real timers by default#46714
Conversation
|
Size Change: 0 B Total Size: 1.32 MB ℹ️ View Unchanged
|
Yes. I'd like to first review and merge #46713, and only then rebase this one on top of |
d15ead7 to
5fdd5e4
Compare
|
The There are just two tests ( |
tyxla
left a comment
There was a problem hiding this comment.
This is amazing, thank you Jarda 🚀
Left a few remarks, but nothing is blocking. I'd only prefer adding a CHANGELOG entry for the jest default preset change before shipping.
| ], | ||
| testPathIgnorePatterns: [ '/node_modules/', '<rootDir>/vendor/' ], | ||
| timers: 'fake', | ||
| timers: 'real', |
There was a problem hiding this comment.
This looks like it will need a CHANGELOG entry. For some relying on fake timers to be the default, this might be a breaking change.
There was a problem hiding this comment.
I'll return to this in a followup. Now my goal is to:
- land this real timers change
- make
useSelectwithuseSyncExternalStorepass all the tests and merge it - try out the "enable concurrent mode" PR with the new
useSelect, to see if the current e2e failures disappear or not
| await user.clear( input ); | ||
| await user.type( input, 'Foo Bar-Baz 9!' ); | ||
| input.blur(); | ||
| act( () => input.blur() ); |
There was a problem hiding this comment.
Maybe we could just trigger a tab and that'd blur it anyway, but in a way resembling user behavior more closely?
| describe( 'PostSlug', () => { | ||
| it( 'should update slug with sanitized input', async () => { | ||
| const user = userEvent.setup( { | ||
| advanceTimers: jest.advanceTimersByTime, |
There was a problem hiding this comment.
We might have to remove that in more places where it's not necessary.
This patch changes the default timers used by Jest unit tests from
faketoreal. That should unblock theuseSelectreimplementation in #46538 whose unit tests are now failing because of a React bug (facebook/react#25889). Changing the default works around that bug and should make the unit tests green again.The patch adds an explicit
jest.useFakeTimers()call to all tests that use fake timers explicitly, i.e., use a Jest API to run the fake timers.The
BorderControltest required somewhat more complex changes, which I'm proposing separately in #46713.