Core: Update diff library, integrate with TapReporter #1788
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 a1
in the above screenshot), and making it easy to understand larger meaningful changes (such as diffinghelloo
andgoodbye
as whole words instead of treating theoo
as semantic overlap and diffing individual letters).