Skip to content

Remove unnecessary boilerplate from snapshots #36

Open
@dantman

Description

@dantman

I'm using snapshot-diff with the custom serializer:

  "jest": {
    "snapshotSerializers": [
      "snapshot-diff/serializer.js"
    ]
}
expect(initialTemplate).toMatchDiffSnapshot(result, {contextLines: 3});

And I'm getting snapshot output like this:

exports[`Template actions setPageTitle should set the meta.title belonging to the page 1`] = `
Snapshot Diff:
- First value
+ Second value

@@ -16,7 +16,7 @@
    "pages": Object {
      "test-01": Object {
        "meta": Object {
-         "title": "Untitled",
+         "title": "Page 1",
        },
      },
      ...
`;

It's a little annoying because these lines are redundant, the test isn't going to cease to be a snapshot diff and I don't need information about how diffs work embedded inside every single snapshot.

Snapshot Diff:
- First value
+ Second value

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions