-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[test] Disable react-transition-group
transitions in unit testing
#16288
[test] Disable react-transition-group
transitions in unit testing
#16288
Conversation
Deploy preview: https://deploy-preview-16288--material-ui-x.netlify.app/ |
@lauri865 @mui/xgrid WDYT about the updated approach of https://reactcommunity.org/react-transition-group/testing/? 🤔 |
Ah, nice find! Seems to break less tests it seems as well. Wonder why they suggested an alternative approach here? 🤔 |
I am not sure; maybe they are suggesting going for maximum efficiency and completely mocking the module to avoid any potential overhead. |
I'm not insinuating it's better. I found it difficult to fake the components due to some state being dependent on transition life-cycle events, hence I overrode props instead. Are you use the latest one works? Transition component children are functions in many instances, and this should error out ("functions are not valid children" yaddayadda). mui-x/test/utils/mochaHooks.js Line 24 in 583b078
If the config prop works, I think it's probably the best bet. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -1776,6 +1777,10 @@ describe('<DataGridPremium /> - Row grouping', () => { | |||
}); | |||
|
|||
it('should add a "Stop grouping {field}" menu item for each grouping criteria on the grouping column when prop.rowGroupingColumnMode = "single"', () => { | |||
const restoreDisabledConfig = config.disabled; | |||
// enable `react-transition-group` transitions for this test | |||
config.disabled = false; |
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.
This test needs animations or refactoring.
@@ -198,6 +199,10 @@ describe('<DataGridPro /> - Column headers', () => { | |||
}); | |||
|
|||
it('should remove the MuiDataGrid-menuOpen CSS class only after the transition has ended', () => { | |||
const restoreDisabledConfig = config.disabled; | |||
// enable `react-transition-group` transitions for this test | |||
config.disabled = false; |
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.
This test needs animations with timeouts or a complete refactor/removal
react-transition-group
transitions in unit testing
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@lauri865 Thank you for the suggestion. 👌 |
It feels as if we can't move forward with this until Data Grid tests are stabilized. 🙈 |
Great work! Curiously though, the unit tests seem to run much slower now 🙈 Although I would pick stability over performance in this case, but still. Regarding randomly breaking tests, tell me about it... wants to make me give up on opening any new PRs. |
packages/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx
Outdated
Show resolved
Hide resolved
It could be due to a slower container. 🤔 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
After merging with the latest |
packages/x-data-grid-pro/src/tests/editComponents.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
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.
Looks good, but I'd do a separate PR to fix those act
calls
…test.tsx Co-authored-by: Jan Potoms <[email protected]> Signed-off-by: Lukas Tyla <[email protected]>
@mui/xgrid should I wait for a review from you, given that test changes are in Grid packages? 🤔 |
…ui#16288) Signed-off-by: Lukas Tyla <[email protected]> Co-authored-by: Lukas <[email protected]> Co-authored-by: Jan Potoms <[email protected]>
…ui#16288) Signed-off-by: Lukas Tyla <[email protected]> Co-authored-by: Lukas <[email protected]> Co-authored-by: Jan Potoms <[email protected]>
An experiment to remove transitions from unit tests in order to make tests more stable. Lots of tests breaking due to
act
errors, which more often than not are related to theTransition
component ofreact-transition-group
. Would be good to disable it globally, and get rid of unnecessarywaitFor
calls as a result to make testing faster as well as more stable.I don't have more time to dig into this now, so will leave it at this, if anyone wants to explore it further. Some tests broke as a result.
UPDATE (Lukas)
config.disabled = true
to disable transitions in mocha and karma testswaitFor
usage where it was possible (mostly since transitions are no longer causing the need for it)