kentcdodds / jest-glamor-react

Jest utilities for Glamor and React
https://npm.im/jest-glamor-react
MIT License
98 stars 24 forks source link

Should this work with babel-plugin-glamorous-displayname #30

Closed aaronjensen closed 6 years ago

aaronjensen commented 6 years ago

Before I work on a repro for this, I just want to know if this should work--we're using both babel-plugin-glamorous-displayname and jest-glamor-react. Our snapshots end up looking like this:

exports[`PageWrapper renders default 1`] = `
.glamor-0,
[data-glamor-0] {
.......

But I would expect them to make use of the displayName (which works in dev). Should this not work with this plugin, or should it and I may have something wrong?

Thanks!

kentcdodds commented 6 years ago

Hey @aaronjensen!

No, they're not intended to work together. In fact, I prefer that they don't. I don't want me changing the name of my component to break a snapshot unit test. I think of that as an implementation detail.

That said, I wouldn't be opposed to exposing an option or something that allowed you to configure this:

https://github.com/kentcdodds/jest-glamor-react/blob/75d1471683940f845e0354e9f43775bf7e6afa9a/src/serializer.js#L17-L24

Where it will not replace the class names with placeholder values and will instead simply return the raw css itself for the snapshot...

aaronjensen commented 6 years ago

Got it, thanks. I'm happy enough as is with it, I mostly wanted to make sure I wasn't missing anything. Feel free to close this if you like.

kentcdodds commented 6 years ago

Sounds good!