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
Configure serializer to skip element attributes on snapshot. #57
Comments
Would be awesome to have this feature. 💯 |
What would it look to configure this? Maybe something like?: import serializer from 'enzyme-to-json/serializer';
import Foo from './Foo'
const compactSerializer = serializer.withExceptions([<ul />, <Foo />]);
expect.addSnapshotSerializer(compactSerializer); |
Hi! Thanks for your suggestions, would you mind giving more details about that? I don't think I understand, you want a snapshot with only elements and inner texts?
|
Ah, I'm realizing that what I wanted was actually quite different from OP, as I had read their post pretty quickly. What I was thinking was something more along the lines of being able to collapse certain elements within a snapshot. So instead of having: <Button
color="blue"
>
<button
className="button blue"
>
</button>
</Button> I could configure my serializer to just return something like: <Button
color="blue"
>
{ [children] }
</Button> This would be awesome for cleaning up snapshots, especially in cases where there's lots of HOC's wrapped up in an implementation. Being able to configure whether I wanted inline props or not would be even more cool, so I could end up with a beautiful snapshot like: <Button color="blue">
{ [children] }
</Button> |
@JonathanTR @dzhytomyrsky @runk I just added a comment to #67 about this new mapping functionality, can you tell me if it solves your issue? Thanks! |
|
Hello is it possible to configure serializer to skip element attributes? It would be wonderful to get on snapshot only elements and innerText.
The text was updated successfully, but these errors were encountered: