Skip to content
This repository was archived by the owner on Oct 25, 2025. It is now read-only.
This repository was archived by the owner on Oct 25, 2025. It is now read-only.

Incorrect Diffing #17

Description

@inadarei

For most but very simple diffs the output is simply incorrect. The root problem seems to be that in JSON the order of elements in the object is insignificant, but the diff used in tap-diff doesn't understand that.

Let's look at this example:

var test = require('tape');
 
test('tape-diff test', function (t) {
    const expected = {
      "one" : "val",
      "two" : "val",
      "three" : "val",
      "four" : "val",
    };

    const actual = {
      "four" : "val",
      "three" : "val",
      "two" : "val",
    };

    t.deepEquals(actual, expected);
    t.end();
});

The proper diff output here is identifying the single missing line:

image

which is what http://www.jsondiff.com/ does.

However, tap-diff doesn't know that the order of elements is insignificant and goes bananas with the diff, producing something akin to:

image

which is pretty useless. And this is an extremely simple example. With a very large and complicated JSON the problem makes tap-diff virtually useless.

Solution

start using the same semantic comparison library that http://www.jsondiff.com/ does to fix the problem. It is: https://github.com/zgrossbart/jdd

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions