diff --git a/packages/material-ui/src/styles/experimentalStyled.test.js b/packages/material-ui/src/styles/experimentalStyled.test.js index dae8a622fca924..3a553c33513451 100644 --- a/packages/material-ui/src/styles/experimentalStyled.test.js +++ b/packages/material-ui/src/styles/experimentalStyled.test.js @@ -7,6 +7,7 @@ import ThemeProvider from './ThemeProvider'; describe('experimentalStyled', () => { const render = createClientRender(); + it('should work', () => { const Div = styled('div')({ width: '200px', @@ -52,43 +53,60 @@ describe('experimentalStyled', () => { }); describe('muiOptions', () => { - const theme = createMuiTheme({ - components: { - MuiTest: { - variants: [ - { - props: { variant: 'rect', size: 'large' }, - style: { - width: '400px', - height: '400px', + /** + * @type {ReturnType} + */ + let theme; + /** + * @type {ReturnType} + */ + let Test; + + before(() => { + theme = createMuiTheme({ + components: { + MuiTest: { + variants: [ + { + props: { variant: 'rect', size: 'large' }, + style: { + width: '400px', + height: '400px', + }, + }, + ], + styleOverrides: { + root: { + width: '250px', + }, + rect: { + height: '250px', }, - }, - ], - styleOverrides: { - root: { - width: '250px', - }, - rect: { - height: '250px', }, }, }, - }, - }); + }); - const testOverridesResolver = (props, styles) => ({ - ...styles.root, - ...(props.variant && styles[props.variant]), - }); + const testOverridesResolver = (props, styles) => ({ + ...styles.root, + ...(props.variant && styles[props.variant]), + }); - const Test = styled( - 'div', - { shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'size' }, - { muiName: 'MuiTest', overridesResolver: testOverridesResolver }, - )` - width: 200px; - height: 300px; - `; + // FIXME: Should not error in DEV + expect(() => { + Test = styled( + 'div', + { shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'size' }, + { muiName: 'MuiTest', overridesResolver: testOverridesResolver }, + )` + width: 200px; + height: 300px; + `; + }).toErrorDev([ + 'You have illegal escape sequence in your template literal', + 'You have illegal escape sequence in your template literal', + ]); + }); it('should work with specified muiOptions', () => { render(Test); diff --git a/test/utils/setupJSDOM.js b/test/utils/setupJSDOM.js index f6f07c519e130a..3dec8168b0f094 100644 --- a/test/utils/setupJSDOM.js +++ b/test/utils/setupJSDOM.js @@ -44,10 +44,6 @@ function throwOnUnexpectedConsoleMessages(methodName, expectedMatcher) { console[methodName] = logUnexpectedConsoleCalls; }); - mochaHooks.beforeEach.push(function resetUnexpectedCalls() { - unexpectedCalls.length = 0; - }); - mochaHooks.afterEach.push(function flushUnexpectedCalls() { const hadUnexpectedCalls = unexpectedCalls.length > 0; const formattedCalls = unexpectedCalls.map(([stack, message]) => `${message}\n${stack}`);