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

Allow character-by-character diffs #25

Closed
lukaszmoroz opened this issue Oct 24, 2021 · 0 comments
Closed

Allow character-by-character diffs #25

lukaszmoroz opened this issue Oct 24, 2021 · 0 comments

Comments

@lukaszmoroz
Copy link

lukaszmoroz commented Oct 24, 2021

jest-diff has implemented two modes of comparing multiline strings:

  • diffLinesUnified for comparing inputs line-by-line - used by diff, which in turn is used by this package;
  • diffStringsUnified, for comparing character-by-character, which is slower but also shows changed substrings within the lines with inverse foreground and background - used by standard equality matchers like toBe.

I have big snapshots with long lines and would prefer to see where exactly in line is the difference.
I suggest changing the diff call to diffStringsUnified or maybe make it configurable if performance is a concern, and set some sensible defaults.

This is for example what jest-diff recommends:

If the input strings can have arbitrary length, we recommend that the calling code set a limit, beyond which splits the strings, and then calls diffLinesUnified instead. For example, Jest falls back to line-by-line comparison if either string has length greater than 20K characters.

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

No branches or pull requests

1 participant