chai-fuzzy icon indicating copy to clipboard operation
chai-fuzzy copied to clipboard

jsonOf/like with custom objects

Open qfox opened this issue 9 years ago • 0 comments

Test case:

var chai = require('chai');
chai.use(require('chai-fuzzy'));
var expect = chai.expect();

function Document() {}
var actual = new Document();
actual.foo = 1;
actual.bar = 2;
var expected = { foo: 1, bar: 2};
expect(actual).to.be.jsonOf(expected);

Expected: no error.

Actual:

      AssertionError: expected { Object (foo, bar, ...) } to be like JSON { Object (foo, bar, ...) }
      + expected - actual

Is this a bug? Is there a way to lossy compare just provided keys?

qfox avatar Aug 19 '15 19:08 qfox