Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dingoeatingfuzz/chai-match-json
A Chai plugin for asserting JSON paths for an object
https://github.com/dingoeatingfuzz/chai-match-json
Last synced: about 2 months ago
JSON representation
A Chai plugin for asserting JSON paths for an object
- Host: GitHub
- URL: https://github.com/dingoeatingfuzz/chai-match-json
- Owner: DingoEatingFuzz
- License: mit
- Created: 2015-01-08T03:46:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-17T00:02:19.000Z (almost 9 years ago)
- Last Synced: 2024-12-06T08:05:52.661Z (about 2 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## matchJSON, for Chai
[![Travis CI](https://travis-ci.org/DingoEatingFuzz/chai-match-json.svg?branch=master)](https://travis-ci.org/DingoEatingFuzz/chai-match-json)
A way to assert the structure of given JSON.
### Examples
It looks like this:```js
var FIXTURE = {
name : 'foo',
value : 'bar',
additional : [ 'prop', 'er', 'ties' ]
};expect(FIXTURE).to.matchJSON({
'$.name' : 'foo',
'$.value' : 'bar'
});
```It uses [JSONPath](https://github.com/s3u/JSONPath) for validating paths. The JSONPath project is well documented
with how to specify path selectors (such as `$.children[3].prices[price<30]`).### Build
```sh
$ browserify lib/match-json.js -o chai-match-json.js
```### Test
```sh
$ npm install -g karma-cli
$ npm install
$ karma start
```