power-assert-runtime icon indicating copy to clipboard operation
power-assert-runtime copied to clipboard

Better string and object diffs

Open twada opened this issue 9 years ago • 6 comments

twada avatar Apr 06 '16 17:04 twada

Any idea where one would start on the path to fixing this?

Whoaa512 avatar May 09 '16 18:05 Whoaa512

@Whoaa512 Thanks!

With this power-assert-runtime project, I'm going to provide a way to power-assert users to create original renderer by themselves.

Developer documentation does not exist yet (sorry), however you will be able to create your pretty-diff renderer like power-assert-renderer-comparison and configure it through power-assert-context-formatter. If you have created a nice one, please contribute us!

twada avatar May 10 '16 10:05 twada

I think it would be great if we were able to build some understanding into the renderer for object diffs and the graph:

var x = {a: 'a', b: 'b', c: 'c', ....lotsMoreProperties};
var y = {a: 'a', b: 'b', c: 'notC', ....lotsMoreProperties};

t.deepEqual(x, y);

Should produce:

t.deepEqual(x, y);
            |  |
            |  {c: 'notC', ...}
            {c: 'c', ...}

In other words, if it's possible, show where objects differ right in the graph, the ... portion can represent how they are the same.

Perhaps we can use color codes. Green ... means no diff was omitted. Red ... means there was a diff to large to be shown in the graph (at which point we add the more conventional multi-line diff below).

jamestalmage avatar Jun 07 '16 15:06 jamestalmage

@jamestalmage Ah, that's nice to have!

twada avatar Jun 10 '16 07:06 twada

The best object diff I've seen to date is the one produced by unexpectedjs. In not sure if that code is really reusable, but I recommend taking a look

Munter avatar Aug 15 '16 09:08 Munter

@Munter Thanks!

twada avatar Aug 15 '16 09:08 twada