I think it would be better if the message of assert.deepEqual was not limited to a depth of 3, and could display the first difference between the objects, like some testing libraries do
constassert=require('assert');assert.deepEqual({foo: {bar: {qux: {lolcat: {bip: {yup: 56}}}}}},{foo: {bar: {qux: {lolcat: {bip: {yup: 56.3}}}}}})// outputs:// AssertionError [ERR_ASSERTION]: { foo: { bar: { qux: [Object] }}} deepEqual { foo: { bar: { qux: [Object] }}}A simple implementation example:
constdeepEq=(o1,o2)=>{constkeys1=Object.keys(o1);constkeys2=Object.keys(o2);if(keys1.length!==keys2.length){assert.deepEqual(o1,o2);}for(leti=0;i<keys1.length;i++){constv1=o1[keys1[i]],v2=o2[keys1[i]];if(v1&&typeofv1==='object'){deepEq(v1,v2);}else{assert.equal(v1,v2);}}};The current implementation passes the entire objects in the Error, and .toString is limited in 3 in depth I guess
I think it would be better if the message of
assert.deepEqualwas not limited to a depth of 3, and could display the first difference between the objects, like some testing libraries doA simple implementation example:
The current implementation passes the entire objects in the Error, and .toString is limited in 3 in depth I guess