https://github.com/timbeyer/chai-samsam
Deep matching chai assertions using samsam
https://github.com/timbeyer/chai-samsam
Last synced: 11 months ago
JSON representation
Deep matching chai assertions using samsam
- Host: GitHub
- URL: https://github.com/timbeyer/chai-samsam
- Owner: TimBeyer
- Created: 2017-07-18T18:44:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-18T19:24:32.000Z (almost 9 years ago)
- Last Synced: 2025-03-26T20:31:18.934Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chai-samsam [](https://travis-ci.org/TimBeyer/chai-samsam) [](https://codecov.io/gh/TimBeyer/chai-samsam)
Extends [Chai](http://chaijs.com/) with an assertion for deeply matching just about any kind of object using [samsam](https://github.com/busterjs/samsam).
This project started out as a fork of [chai-deep-match](https://github.com/JamesMGreene/chai-deep-match).
Its interface and test cases have been retained and all pass. Thus it can be used as a drop in replacement.
However, it allows for much looser and deeper matching. ([See the samsam docs](https://github.com/busterjs/samsam#matchobject-matcher))
## Install
```shell
$ npm install --save chai
$ npm install --save chai-samsam
```
## Usage
```js
const chai = require('chai')
const chaiSamSam = require('chai-samsam')
chai.use(chaiSamSam)
expect([{
firstName: 'John',
lastName: 'Doe',
jobs: [{ bartender: true, barista: true }]
}]).to.deep.match([
{ jobs: [{ barista: true }] }
])
// => pass
expect([{
firstName: 'John',
lastName: 'Doe',
jobs: [{ bartender: true, barista: true }]
}]).to.not.deep.match([
{ jobs: [{ pilot: true }] }
])
// => pass
// also possible
assert.deepMatch(a, b)
assert.notDeepMatch(a, b)
```
## License
Copyright (c) 2017, Tim Beyer (MIT License)