[TabContext] Introduced new prop to allow deterministic button ids on tabs#47715
[TabContext] Introduced new prop to allow deterministic button ids on tabs#47715filipomar wants to merge 1 commit intomui:masterfrom
Conversation
Netlify deploy previewhttps://deploy-preview-47715--material-ui.netlify.app/ Bundle size report
|
mj12albert
left a comment
There was a problem hiding this comment.
The generated ids are an implementation detail of the library and snapshot tests aren't great for this reason
Have you tried mocking Math.random in your tests as suggested in the comments of the linked issue?
Yes, we are mocking them as linked on the original PR and that works "fine". However I find it cumbersome to have to have this additional mocking and wanted a way to provide my own generated ids (through this PR) so that is also not needed anymore. Regarding this PR, if this solution isn't good enough, I could probably work on an alternative with a non random and non injected id as well. |
While running my own tests, which relied on the tabs, I couldn't get a deterministic snapshot of them.
I have visited this issue before on PR #38192 (but got side tracked)
And it fixes Issue #32038
I decided to make a simpler set of changes this time around, simply exposing the Math.random to be replaced.