# chai-json

> A chai plugin to validate json files

Latest version **1.0.0** (published 2018-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install chai-json
pnpm add chai-json
yarn add chai-json
bun add chai-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-01-31 |
| First published | 2017-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | giper |
| Maintainers | giper |
| Keywords | chai-json, array, assert, assertion, chai-plugin, json, objects, test, testing, chai |

## Links

- npm: https://www.npmjs.com/package/chai-json
- Repository: https://github.com/giper45/chai-json
- Homepage: https://github.com/giper45/chai-json#readme
- Issues: https://github.com/giper45/chai-json/issues
- npm.io page: https://npm.io/package/chai-json

## Dependencies (3)

- [chai](https://npm.io/package/chai.md) ^3.5.0
- [jsonfile](https://npm.io/package/jsonfile.md) ^3.0.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-01-31
- 0.1.1 — 2017-05-11
- 0.1.0 — 2017-05-11

## README

# chai-json
A chai plugin to validate json files


## Usage

### server-side

Install from npm:

    $ npm install chai-json

Have chai use the chai-fs module:

    var chai = require('chai');
    chai.use(require('chai-json'));



## Assertions

### jsonFile()

Assert that a file is a json
 

	expect(testFile).to.be.a.jsonFile();
  



### jsonObj()

Assert that the jsonFile given is equal to an javascript object.
     
     expect(testFile).to.be.a.jsonFile().and.to.be.jsonObj(jsonObj);
 


### jsonWithProps()

Assert that the jsonFile contains an object with given properties
```javascript

    /* 
    Content of testFile:  
 [{"repoName":"giper","labName":"TelnetClientSniffing_1","state":"STOPPED"},{"repoName":"giper","labName":"ErrorSameSubnet","state":"STOPPED"},
 {"repoName":"giper","labName":"ErrorSamePort","state":"STOPPED"},    
 {"repoName":"giper","labName":"ErrorWrongAction","state":"STOPPED"},{"repoName":"giper","labName":"ErrorNoDefinedAction","state":"NO_NETWORK"},{"repoName":"giper","labName":"ErrorCopyFile","state":"STOPPED"},
 {"repoName":"giper","labName":"TestActionNoArgs","state":"STOPPED"}
 ]
    */ 
    expect(testFile).to.be.a.jsonFile().and.contain.jsonWithProps({ repoName: 'giper' });
```
 

## Contributing

Contributions are welcome. Please follow the code, test and style patterns and keep Eslint happy. Look at Airbnb style guide for more informations. 

## Build & test

Install development dependencies in your git checkout:

    $ npm install

Run tests:

    $ mocha test





## License

Licensed under the MIT license.

---
_Source: https://npm.io/package/chai-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
