diff --git a/packages/mui-styles/src/withStyles/withStyles.test.js b/packages/mui-styles/src/withStyles/withStyles.test.js
index f739276ae56d0d..6b9170aa89c26a 100644
--- a/packages/mui-styles/src/withStyles/withStyles.test.js
+++ b/packages/mui-styles/src/withStyles/withStyles.test.js
@@ -135,7 +135,16 @@ describe('withStyles', () => {
const jssCallbackStub = stub().returns({});
const styles = { root: jssCallbackStub };
const StyledComponent = withStyles(styles)(MyComp);
- render();
+ const renderCb = () => render();
+
+ // React 18.3.0 started warning for deprecated defaultProps for function components
+ if (React.version.startsWith('18.3')) {
+ expect(renderCb).toErrorDev([
+ 'Warning: MyComp: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.',
+ ]);
+ } else {
+ renderCb();
+ }
expect(jssCallbackStub.callCount).to.equal(1);
expect(jssCallbackStub.args[0][0]).to.deep.equal({
@@ -178,24 +187,33 @@ describe('withStyles', () => {
const styles = { root: { display: 'flex' } };
const StyledComponent = withStyles(styles, { name: 'MuiFoo' })(MuiFoo);
-
- const { container } = render(
-
+ render(
+
-
- ,
- );
+ })}
+ >
+
+ ,
+ );
- expect(container).to.have.text('bar');
+ // React 18.3.0 started warning for deprecated defaultProps for function components
+ if (React.version.startsWith('18.3')) {
+ expect(renderCb).toErrorDev([
+ 'Warning: MuiFoo: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.',
+ ]);
+ } else {
+ renderCb();
+ }
+
+ expect(screen.getByText('bar')).not.to.equal(null);
});
it('should work when depending on a theme', () => {