Open leobalter opened 8 years ago
Straw man:
interface Diff {
kind: 'line' | 'word',
expected: string,
actual: string
}
It would also be great to have a lower-level interface we could use to specify the differences in a format like this:
[
{ "type": "context", "line": "..." },
{ "type": "removed", "line": "..." },
{ "type": "added", "line": "..." },
{ "type": "context", "line": "..." }
]
That's a bit more complex than my initial proposal but I'm interested on seeing this implemented.
@gibson042 @trentmwillis what do you think?
@leobalter I'm fine with any level of abstraction :smile:
I just fleshed out perhaps an Ultimate(tm) version of the feature.
This seems reasonable to me. A couple thoughts:
I'm not ready to accept this particular low-level strawman now, but I like extending pushResult
's argument to include diff data that overrides/replaces actual
and expected
. And I can see different reporters wanting different formats (e.g., HTML vs. ANSI-escaped vs. patch vs. structured tuples vs. …), so a function or an object with methods (which I suppose toString
is implicitly) is also more appealing to me than a string value.
As requested by @wycats, it would be good to extend
Assert#pushResult
to receive a custom diff value, where it does not replace the defaultQUnit.diff
(still useful for other assertions) but it prints a customized diff value.Examples:
If diff is given, QUnit should get its value and ignore calling the default QUnit.diff.