-
-
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] Remove createMount test util #42703
Conversation
1df7b07
to
e42bf4c
Compare
Netlify deploy previewhttps://deploy-preview-42703--material-ui.netlify.app/ Bundle size report |
* returns a function that given the props for the styles object will return | ||
* the css classes | ||
* @param {object} styles argument for `makeStyles` | ||
*/ | ||
function createGetClasses(styles) { | ||
const useStyles = makeStyles(styles); | ||
const output = {}; | ||
|
||
function TestComponent(props) { | ||
output.classes = useStyles(props); | ||
return <div />; | ||
} | ||
|
||
return function mountWithProps(props) { | ||
const wrapper = mount(<TestComponent {...props} />); | ||
output.wrapper = wrapper; | ||
return output; | ||
}; | ||
} |
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 custom setup has been replaced by using the renderHook
directly. I think this makes tests easier to read by having less custom abstractions.
'MUI: The `styles` argument provided is invalid.\nYou are providing a function without a theme in the context.', | ||
'MUI: The `styles` argument provided is invalid.\nYou are providing a function without a theme in the context.', | ||
'Uncaught [TypeError: theme.spacing is not a function', |
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 why errors are now duplicated, probably due to effects running twice now that renderHook
is used. We pass strict: false
to createRenderer
(and to createMount
before) in this test suite. Maybe we could look into creating our own renderHook
wrapper with this option.
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 package is not compatible with strict mode, so yes, we need to have that option.
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.
We can tackle this in another PR to not make this PR even bigger.
expect(sheetsRegistry.registry.length).to.equal(2); | ||
expect(sheetsRegistry.toString()).to.equal(`.makeStyles-root-2 { | ||
color: white; | ||
background-color: black; | ||
}`); | ||
|
||
act(() => { |
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.
fireEvent
already handles act
for us.
bb99a64
to
4bbf1aa
Compare
4bbf1aa
to
8583690
Compare
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.
Great job @aarongarciah! I only have one question: #42703 (comment)
Part of #42454
Warning
A lot of tests have been modified, pay special attention while reviewing. Highly recommended to review commit by commit.
Highlights:
createMount
util from@mui/internal-test-utils
in favor ofcreateRender
.mount
argument indescribeConformanceUnstyled
calls was unused, it has been removed from all Base UI tests.createRender
instead ofcreateMount
.findOutermostIntrinsic
andwrapsIntrinsicElement
from@mui/internal-test-utils
. They seem unused across our code bases.Some of the tests have been updated to not rely on implementation details (e.g. props introspection) now that Enzyme is gone.