-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
jest --coverage
causes display name to change
#151
Comments
I found a temporary solution by setting the displayName manually.
|
Hmm. So this happens because of the instrumentation babel is adding, which
changes the line order of the files and then consequently the component
hashes.
Do you have SSR mode on for the plugin? That might help.
…On Wed, Aug 15, 2018 at 9:50 AM Ian Edington ***@***.***> wrote:
I found a temporary solution by setting the displayName manually.
IconCircle.displayName = 'IconCircle';
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#151 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAiy1lsaLEJDGRyebSl90QEBLoZPlcBQks5uRDUogaJpZM4V8in7>
.
|
Interesting. Thanks for explaining that. enabling SSR mode on the styled-components babel plugin doesn't seem to have an effect. This is what I'm using:
with coverage still fails |
Okay, one other idea: for babel environment “test” (what jest uses) set the
plugin option displayName: false. I think this might help counteract what
Istanbul (the instrumentor) is doing.
|
@IanEdington Did you by chance have time to test the above? Your babelrc would look something like this: {
"plugins": ["styled-components"],
"env": {
"test": {
"plugins": [["styled-components", { "displayName": false }]]
}
}
} |
Thanks for following up Yes I did. Instead of |
I mean I wouldn’t really rely on snapshot tests for this sort of thing
anyway to be honest. The way the components are named are not part of the
public API, so they could change at any time.
|
To be clear, the way components are named is absolutely a part of the public API - the API is everything observable - so changing them must follow semver just like anything else. |
I get different display names for this component depending on if I run jest with
--coverage
or not.with
yarn jest --env=jsdom
I getReportIssueModal__IconCircle
with
yarn jest --env=jsdom --coverage
I getStyled(Circle)
The text was updated successfully, but these errors were encountered: