Skip to content
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

Remove unnecessary boilerplate from snapshots #36

Open
dantman opened this issue Mar 17, 2018 · 3 comments
Open

Remove unnecessary boilerplate from snapshots #36

dantman opened this issue Mar 17, 2018 · 3 comments

Comments

@dantman
Copy link

dantman commented Mar 17, 2018

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

@thymikee
Copy link
Member

thymikee commented Mar 17, 2018

Hm, maybe we should only leave this "legend" feature for the React components or even remove at all (because it gets messy with components having more props). Indeed it doesn't provide any value, as I see it now.

If you ask me, I'm happy to accept a PR changing it and publish as a major version bump.

@thymikee
Copy link
Member

cc @ferrannp @kentcdodds @jlongster

@kentcdodds
Copy link
Contributor

I like the heading. I say keep it. If it's not there then folks seeing the snapshot could be confused. Especially if they break it making seemingly unrelated changes and see the output in their terminal which is quite hard to understand frankly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants