[code-infra] Optimize `@testing-library/user-event`
See this thread
I've seen this reduce the time of running userEvent.keyboard by an order of magnitude, eliminating the motivation to avoid using this library. It comes at the cost of slightly changed semantics. But even with these different semantics, we'd be better off compared to the way we currently test.
It would be best for us to primarily optimize our tests for refactorability. Tests that require updates on every implementation detail change miss the mark. We should aim at tests that maximize interfacing with public API and minimize reliance on implementation details. Therefore, unless we specifically want to test an implementation detail, we should prefer userEvent.
Closes https://github.com/mui/mui-x/pull/14668
Netlify deploy preview
https://deploy-preview-43804--material-ui.netlify.app/
Bundle size report
| Bundle | Parsed size | Gzip size |
|---|---|---|
| @mui/material | 0B(0.00%) | 0B(0.00%) |
| @mui/lab | 0B(0.00%) | 0B(0.00%) |
| @mui/system | 0B(0.00%) | 0B(0.00%) |
| @mui/utils | 0B(0.00%) | 0B(0.00%) |
Generated by :no_entry_sign: dangerJS against 45bb823db5e2963daeb219fd28424dabe991ea5d
Can this break MUI X tests?
Technically yes, but unlikely. We could try it out before merging.
Do we need to release this in a way that allows some tests to configure this behavior?
We could add a parameter to createRenderer, but you can also just set up your own const user = userEvent.setup() instance and use that for a specific test. IMO over time we should work towards moving things out of createRenderer and make the wrapper unnecessary.
🙂 Yep, trying this in X breaks the tests, ~but looks like it's not caused by this change, see https://github.com/mui/mui-x/pull/14671~
Edit: Looks like it now fails consistently
closing as it breaks X