Ava: Empty diff because of .toJSON

Created on 6 Feb 2017  路  3Comments  路  Source: avajs/ava

Using deepEqual with object with .toJSON method produce empty diff

Test Source

Example with underscore chain object

var test = require('ava'),
    _ = require('underscore');

test(function(t) {
    t.deepEqual(_([1, 2]).chain(), [1, 2]);
});

Error Message & Stack Trace

$ ava test.js 

  1 failed

  [anonymous]
  test.js:5

   4: test(function(t) {                       
   5:   t.deepEqual(_([1, 2]).chain(), [1, 2]);
   6: });                                      

  Difference:


  Test.fn (test.js:5:4)

$ node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v4.4.7
linux 4.4.0-59-generic
$ ava --version
0.18.1
$ npm --version
2.15.8

bug

Most helpful comment

Perhaps if we can't compute a diff then we should not display the "Difference" section at all.

All 3 comments

pretty-format has an option callToJSON that true by default, maybe this is a reason?

Hmm, I will look into this, thanks for reporting!

Perhaps if we can't compute a diff then we should not display the "Difference" section at all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

electerious picture electerious  路  3Comments

kozzztya picture kozzztya  路  5Comments

nickjanssen picture nickjanssen  路  4Comments

ehmicky picture ehmicky  路  3Comments

sindresorhus picture sindresorhus  路  5Comments