Skip to content

MediaComem/chai-objects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chai-objects

Chai assertion to check an array of objects.

npm version Dependency Status Build Status Coverage Status License

Developed at the Media Engineering Institute (HEIG-VD).

Installation

$> npm install --save-dev chai-objects

Usage

const chai = require('chai');

chai.use(require('chai-objects'));

chai.expect([
  { corge: 'grault' }, // this object is expected
  { qux: 'warply' }    // this object is not expected
]).to.have.objects([
  { foo: 'bar' },          // this object is missing
  { bar: { baz: 'qux' } }, // this object is missing
  { corge: 'grault' },
]);

// AssertionError: expected to find the following missing objects:
// - {"foo":"bar"}
// - {"bar":{"baz":"qux"}}
//
// The following extra objects were found:
// - {"qux":"warply"}