[code-infra] Improve Tooltip leaveDelay test#47624
Conversation
Netlify deploy previewhttps://deploy-preview-47624--material-ui.netlify.app/ Bundle size report
|
ZeeshanTamboli
left a comment
There was a problem hiding this comment.
I had tried using clock.tickAsync but I thought it isn't available because it didn't show in IntelliSense. Also, immediate assertion make sense.
Would be great if this is accepted and merge quickly. The flakiness is very annoying and time consuming.
| expect(screen.getByRole('tooltip')).toBeVisible(); | ||
|
|
||
| await flushMicrotasks(); | ||
| await clock.tickAsync(2); |
There was a problem hiding this comment.
Shouldn't this move forward by 1?
There was a problem hiding this comment.
I'm moving it by 2 so we test at 1ms before and 1ms after the exact point in time at which we want the tooltip to leave. Removes all ambiguity that the exact ms tick has when the leave delay ends.
| @@ -1,3 +1,4 @@ | |||
| 'use client'; | |||
There was a problem hiding this comment.
By mistake? Or correct?
| 'use client'; |
There was a problem hiding this comment.
Correct, it's using react context
It isn't, I updated |
clock.tickAsyncinstead ofclock.tickto properly handle async React updatesleaveDelayis applied if you don't verify the tooltip is still there right before it fires?)jsdomresolution after@mui/internal-test-utilsupdateThis may also address the flakeyness we've been seeing lately