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

Core: Update diff library, integrate with TapReporter #1788

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Krinkle
Copy link
Member

@Krinkle Krinkle commented Jul 26, 2024

We embed an old version of the diff-match-patch library for use in the HTML Reporter. The latest version has some improvements that I think reduce noise, and its line-based text mode (i.e. not HTML tags) makes it suitable for CLI use, so we can integrate it in the TAP reporter.

Our wrapping functions are at the end of src/core/diff.js.

It seemed like the library has built-in methods to generate a unified diff, but I couldn't get it to work well in practice, so I'm reducing it to a line-blocks first and adding plus/minus symbols manually in our wrapping function. Perhaps there's a better way?

Ref #1412.

Before After
Screenshot Screenshot
  • More reliably skip diff when it's only "plus all of expected, minus all of actual".
  • The updated version of diff-match-patch has slightly better semantic/word thresholds.
    It thus creates a slightly different balance between making it easy to spot subtle differences (diffing the exact character, such as adding an s or missing a 1 in the above screenshot), and making it easy to understand larger meaningful changes (such as diffing helloo and goodbye as whole words instead of treating the oo as semantic overlap and diffing individual letters).

@Krinkle Krinkle marked this pull request as draft July 26, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant