Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support custom snapshot serializers on diff inputs #30

Closed
motiz88 opened this issue Feb 9, 2018 · 3 comments · Fixed by #91
Closed

Support custom snapshot serializers on diff inputs #30

motiz88 opened this issue Feb 9, 2018 · 3 comments · Fixed by #91

Comments

@motiz88
Copy link

motiz88 commented Feb 9, 2018

My exact use case for this involves migrating from react-test-renderer to enzyme.mount - the former is natively supported by pretty-format while the latter ships with a custom serializer.

Would it make sense for snapshot-diff to support an API similar to expect.addSnapshotSerializer? Maybe with a slightly more hygienic twist:

import snapshotDiff from "snapshotDiff";
import enzymeToJson from "enzyme-to-json/serializer";

const diff = snapshotDiff.withSerializers([enzymeToJson]);
diff(a, b); // Runs `a` and `b` through the given serializers before diffing

I'm happy to put together a PR for this over the next few days.

@thymikee
Copy link
Member

thymikee commented Feb 9, 2018

Happy to review, seems like a handy feature. Serializers are just pretty-format plugins, so hopefully this will be pretty straight-forward to implement.

@SimenB @pedrottimark are you ok with the API proposal? I thought about snapshotDiff.[use/add]Plugins([...]) or snapshotDiff.[use/add]Serializers([...]). But I like .withSerializers() too

@SimenB
Copy link
Member

SimenB commented Feb 10, 2018

Yeah, that sounds good!

@siebigteroth
Copy link

Any updates on this? :-)

alistairjcbrown added a commit to alistairjcbrown/snapshot-diff that referenced this issue Sep 15, 2019
Provides new addSerializers function to add additional serializer
objects to be used before diffing.

Fixes jest-community#18
Fixes jest-community#30
alistairjcbrown added a commit to alistairjcbrown/snapshot-diff that referenced this issue Sep 15, 2019
Provides new addSerializers function to add additional serializer
objects to be used before diffing. React component serializer
implementation using `react-test-renderer` has been extracted out.

Fixes jest-community#18
Fixes jest-community#30
alistairjcbrown added a commit to alistairjcbrown/snapshot-diff that referenced this issue Sep 23, 2019
Provides new setSerializers function to set the serializer objects to
be used before diffing. React component serializer implementation using
`react-test-renderer` has been extracted out.

Fixes jest-community#18
Fixes jest-community#30
Fixes jest-community#31
alistairjcbrown added a commit to alistairjcbrown/snapshot-diff that referenced this issue Sep 23, 2019
Provides new setSerializers function to set the serializer objects to
be used before diffing. React component serializer implementation using
`react-test-renderer` has been extracted out.

Fixes jest-community#18
Fixes jest-community#30
Fixes jest-community#31
alistairjcbrown added a commit to alistairjcbrown/snapshot-diff that referenced this issue Nov 4, 2019
Provides new setSerializers function to set the serializer objects to
be used before diffing. React component serializer implementation using
`react-test-renderer` has been extracted out.

Fixes jest-community#18
Fixes jest-community#30
Fixes jest-community#31
thymikee pushed a commit that referenced this issue Nov 5, 2019
Provides new setSerializers function to set the serializer objects to
be used before diffing. React component serializer implementation using
`react-test-renderer` has been extracted out.

Fixes #18
Fixes #30
Fixes #31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants