question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Explain diff gutter symbols

See original GitHub issue

Issuehunt badges

Please see this comment: https://github.com/avajs/ava/issues/1558#issuecomment-469031454

Original issue follows.


Description

When using t.snapshot(foo) and foo does not match the snapshot, the diff that is shown uses - to indicate the new foo values and + to show the old foo values.

This is unintuitive.

I believe the problem may be at https://github.com/avajs/ava/blob/14f7095d25abc5ffbff7efd7db962eaf5e86daab/lib/assert.js#L321

Test Source

import test from 'ava'
test('snapshot diff', t => {
  t.snapshot(`\n${Date.now()}\n`, 'the - value should be less than the + value')
})

Environment

Latest stable ava on OS X


IssueHunt Summary

Backers (Total: $60.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nesbocajcommented, Mar 29, 2018

@arteniioleg Jest should only be confusing if you assume the colors have the same purpose, they don’t. In Git the colors signifies changes, with green signifying added/new, and red, removed/old. Whereas in Jest the colors signify (the assumed) correctness of the value, with green signifying correct, and red, incorrect.

In both instances the preceding symbol signifies changes, with + signifying added/new, and -, removed/old.

It’s also worth noting that Jest goes quite far in explaining (or at least trying to explain) this concept to the user.

1reaction
wmertenscommented, Mar 1, 2018

Yes, the way Jest does it looks good!

On Thu, Mar 1, 2018 at 12:53 PM rzec-r7 notifications@github.com wrote:

@novemberborn https://github.com/novemberborn any update on this? I have been tripped up by the + / - difference with AVA so many times.

I think what @nesbocaj https://github.com/nesbocaj said makes sense. For me the colors are not as important as the - / + and since snapshots are tests that are just diffing 2 values, it make the most sense to have the - be the existing value in the snapshot and the + be the new value from the test (I have not opinion on the colors, probably makes to to just match what jest does).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/avajs/ava/issues/1558#issuecomment-369568743, or mute the thread https://github.com/notifications/unsubscribe-auth/AADWlhVQfoQ2qiR_dK-UIn26li2_F1Wlks5tZ-FSgaJpZM4QAMuE .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Settings - GitGutter Documentation
GitGutter provides support for custom gutter icons and diff popup style sheets coming with theme packages. Set theme to a valid theme file...
Read more >
Icon reference | IntelliJ IDEA Documentation - JetBrains
Gutter icons are located in the editor on the left. Every icon in the gutter has a tooltip that explains its meaning and...
Read more >
Transition and Gutters | Understanding Comics - WordPress.com
McCloud describes six types of panel-to-panel transitions, each requiring a different degree of closure from the reader. The first, and most simple, is...
Read more >
What are these arrow (») and plus and minus symbols that just ...
The plus and minus signs seem to be git diff symbols, but before it used to be ... plus or minus symbol controlled...
Read more >
GitGutter - Package Control
Gutter Icons indicating inserted, modified or deleted lines; Diff Popup with details about modified lines; Status Bar Text with information about file and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found