lorenzofox3 / zora

Lightest, yet Fastest Javascript test runner for nodejs and browsers
MIT License
539 stars 93 forks source link

Switching between character/line diff? #127

Closed mindplay-dk closed 11 months ago

mindplay-dk commented 2 years ago

In the diff reporter, can we have some means of switching between diffChars and diffLines?

diffChars works well for individual strings, but doesn't work so well for multi-line content.

(This is also (presumably) why diffJson internally uses the lineDiff tokenizer.)

The simplest option, I think, would be to have diffStrings check for line-breaks in expected - if line-breaks are present, use diffLines instead of diffChars, which would give an output more similar to that of diffObjects.

Perhaps better, if expected contains line-breaks, to do both a line diff and a character diff, and see which one yields the fewest results - and then render that as the result.

For me, personally, the simplest option would work: just treat multi-line strings as lines.

lorenzofox3 commented 2 years ago

That sounds like a good idea