-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Update matchMedia
mocks
#43240
[test] Update matchMedia
mocks
#43240
Conversation
Netlify deploy previewBundle size report |
addListener: () => {}, | ||
removeListener: () => {}, | ||
addEventListener: () => {}, | ||
removeEventListener: () => {}, |
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.
On second thought, it should mock both here to work with both v5 and v6.
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.
Not sure I follow. This PR is supposed to land on next
(v6). How does keeping addListener
/removeListener
help v5?
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.
Given the current release strategy for the internal packages, this should probably be a major release of the @mui/internal-test-utils
and dropping the addListener
altogether as the linked PR for removing Safari support did. 🤔
What do others think?
cc @mui/code-infra
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 PR is supposed to land on next (v6). How does keeping addListener/removeListener help v5?
We're using the @mui/internal-test-utils
released from the next
branch, but we can run our tests using either @mui/material
v5 or v6. Since @mui/material@5
still uses addListener
/removeListener
, we need both to run the tests against both v5 and v6.
Does this make sense?
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.
Got it 👍
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.
Given the current release strategy for the internal packages, this should probably be a major release of the
@mui/internal-test-utils
We're not following semver with internal packages. The strategy is to be always backwards compatible (*). So I believe supporting both as @cherniavskii does makes most sense to me 👍
(*) backwards compatible against our own code that is. As soon as none of our code uses the compatibility mode anymore, it can be dropped, even on a minor.
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.
Sounds good 👍🏻
This PR is ready for review then.
Is the failed "CI / test-dev (macos-latest) (pull_request)" step a false alarm? I'm not sure my changes could have caused it 🤔 |
Can't reproduce locally ( |
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.
Suggestion: It could be valuable to have a comment that explains why the legacy methods are still there and when they can be removed.
The usage of deprecated
addListener
/removeListener
was removed fromuseMediaQuery
in https://github.com/mui/material-ui/pull/42464/files#diff-29dc32373d28b87f1bf18f66cfb725f9dbad15b86a308c8453aa0ce38d15c748L92describeConformance
still mocks the deprecated methods, which makes the tests in MUI X fail when running against@mui/material@^6
:This PR updates the
matchMedia
mocks to useaddEventListener
/removeEventListener
.