Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/mediacomem/chai-objects
- Owner: MediaComem
- License: mit
- Created: 2017-11-29T16:14:37.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-29T16:22:12.000Z (about 7 years ago)
- Last Synced: 2024-12-05T14:47:13.163Z (about 2 months ago)
- Topics: assertion, chai, objects
- Language: JavaScript
- Size: 23.4 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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"}
```