chai-properties
Intallation:
npm install --save chai-properties
Properties matcher for chai
Make assertions that values have all the same attributes and values without asserting strict object equality.
browser-side
include chai properties after chai:
server-side
have chai use chai-properties:
var chai = ;chai;
Assertions
properties(object)
partially compare object attributes and values
var subject = a: 'a' b: 'b' c: 'c' ;subjectshouldhave;subjectshouldhave;subjectshouldnothave;subjectshouldnothave; tohave;tohave;tonothave;tonothave; assert;assert;assert;assert;
Difference between expectation and actual result
properties
assertion will show difference between expectation and actual result when asserion will fail.
var subject = a: 'a' b: 'b' c: 'c' ;tohave;
AssertionError: expected { a: 'a', b: 'b', c: 'c' }
to have properties { a: 'a', b: 'c' }, but found { a: 'a', b: 'b' }
+ expected - actual
{
"a": "a"
- "b": "b"
- "c": "c"
+ "b": "c"
}