Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mediacomem/chai-objects

Chai assertion to check an array of objects.
https://github.com/mediacomem/chai-objects

assertion chai objects

Last synced: about 1 month ago
JSON representation

Chai assertion to check an array of objects.

Awesome Lists containing this project

README

        

# chai-objects

[Chai](http://chaijs.com) assertion to check an array of objects.

[![npm version](https://badge.fury.io/js/chai-objects.svg)](https://badge.fury.io/js/chai-objects)
[![Dependency Status](https://gemnasium.com/badges/github.com/MediaComem/chai-objects.svg)](https://gemnasium.com/github.com/MediaComem/chai-objects)
[![Build Status](https://travis-ci.org/MediaComem/chai-objects.svg?branch=master)](https://travis-ci.org/MediaComem/chai-objects)
[![Coverage Status](https://coveralls.io/repos/github/MediaComem/chai-objects/badge.svg?branch=master)](https://coveralls.io/github/MediaComem/chai-objects?branch=master)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE.txt)

- [Installation](#installation)
- [Usage](#usage)

Developed at the [Media Engineering Institute](http://mei.heig-vd.ch) ([HEIG-VD](https://heig-vd.ch)).

## Installation

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

## Usage

```js
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"}
```