groupon / assertive

Assertive is a terse yet expressive assertion library
BSD 3-Clause "New" or "Revised" License
21 stars 11 forks source link

Reporting for undefined diffs in deepEqual is unhelpful #7

Open dbushong opened 10 years ago

dbushong commented 10 years ago
assert.deepEqual { x: 42 }, { x: 42, y: undefined }
Error: deepEqual {"x":42} failed on something that
serializes to the same result (likely some function)

In this case it's a tiny structure and easy to hunt down, but for large structures figuring out which thing has an undefined can be odious.

EndangeredMassa commented 10 years ago

This would require some smarter deepEqual logic.

@johan thoughts?

johan commented 10 years ago

I couldn't agree more; patches to improve this situation are warmly welcome and encouraged.

The current output is one step up from stating your two objects did not match, and showing two huge identical JSON serializations, which I think was the behaviour of assertive's predecessor.

The not-yet-exposed stringify (with potential additional needed tweaks) might be one approach, but I assume non-serialization-based logic in deepEqual is the more solid workable approach.

EndangeredMassa commented 10 years ago

Something like deep-diff might be useful for displaying the differences in a concise way.