nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.41k stars 29k forks source link

Expose `createErrDiff` for diffing objects #51740

Open JMTK opened 6 months ago

JMTK commented 6 months ago

What is the problem this feature will solve?

I like the general format of the deepStrictEqual diff comparisons, but it would be nice to get this functionality "natively" to print a diff instead of forcing it to error to see a diff.

What is the feature you are proposing to solve the problem?

Expose createErrDiff from assert https://github.com/nodejs/node/blob/544cfc5ef151bca8d625fbccc581200a77b00bc0/lib/internal/assert/assertion_error.js#L79

What alternatives have you considered?

Userland diff tool, but if the code is already there it would be nice to expose it

BridgeAR commented 5 months ago

The current implementation is not ideal. I would not expose that for now. It is just a best effort implementation and not e.g., Myers .