A function returns an array of objects. When I compare the actual result with an expected result using JSON.stringify the values are identical. However comparison using should.deep.equal or _.isEqual fails. Had anyone encountered such issue?
I've realized what the issue was. It is caused by the fact that JSON.stringify misses fields with undefined values. E.g. result of applying JSON.stringify to the following object {field: 'value', undefinedField: undefined} is {"field": "value"}. Hence
JSON.stringify({field: 'value', undefinedField: undefined}) === JSON.stringify({field: 'value'})`
But
{field: 'value', undefinedField: undefined}.should.deep.equal({field: 'value'})
fails