-
-
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] Throw on console.(error|warn) outside of test #22907
Conversation
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', | ||
]); |
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.
@mnajdova Any idea why this is happening?
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.
Nice! I was wondering where this warning was coming from!
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.
I am not sure why it is happening. Let's replace the string template with object:
({
width: '200px',
height: '300px',
})
and it will go away. I will try to repro it on a simple example and report 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.
Update, even just adding round bracket around it solves the issue 🤷 :
(`
width: 200px;
height: 300px;
`)
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.
https://codesandbox.io/s/objective-vaughan-6r3u0?file=/src/App.js
Found the issue, seems like the destructuring on line 31 causes the warning:
return defaultStyledResolver(...stylesWithDefaultTheme);
If I remove it the warning is gone.
return defaultStyledResolver(stylesWithDefaultTheme);
However, styled-components
was not working without the destructuring. - https://codesandbox.io/s/illegal-escape-warning-styled-components-9ug0i?file=/src/App.js so I would propose to not change anything at this moment. If in the next version of emotion the warning is fixed, we can update it. Does that makes 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.
Sounds like this is what the adapter packages were made for.
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.
True, I will try to update them today and test again
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.
Marked as FIXME. Needs to be fixed before release. For now we keep the expectation so that we don't add noise to the console output.
No bundle size changes comparing fcee9db...d137f10 |
c644ea8
to
d137f10
Compare
Should be reviewed without whitespace diff.
Get rid of "You have illegal escape sequence in your template literal" console messageLeaving a FIXME
it()
now throwsI don't know anymore if this was intentional or not.
experimentalStyled.test
intobefore
Tests should be side-effect free i.e. don't execute any code.
If they do you'll have a hard time locating the issue.
It also slows down the overall test suite when doing
--grep
because test runners have to evaluate the full test suite. But this is more of a "death-by-thousand-cuts" scenario