Skip to content

Support custom snapshot serializers on diff inputs #30

Closed
@motiz88

Description

@motiz88

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions