https://github.com/jsdir/chai-jsend
Chai plugin for asserting JSend responses.
https://github.com/jsdir/chai-jsend
Last synced: 4 months ago
JSON representation
Chai plugin for asserting JSend responses.
- Host: GitHub
- URL: https://github.com/jsdir/chai-jsend
- Owner: jsdir
- License: mit
- Created: 2014-08-18T15:53:12.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-11T00:02:03.000Z (over 11 years ago)
- Last Synced: 2025-03-16T12:31:51.775Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 180 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
chai-jsend
==========
[](https://travis-ci.org/jsdir/chai-jsend)
[](https://david-dm.org/jsdir/chai-jsend)
[](https://www.npmjs.org/package/chai-jsend)
Chai plugin for asserting JSend responses.
Installation
------------
`npm install --save-dev chai-jsend`
Assertions
----------
## Success
- `success`
- `successWith`
### Usage:
```js
describe('success', function() {
it('should succeed', function(done) {
req.get('/users/1').end(function(err, res) {
if (err) {return done(err);}
res.should.be.success;
res.should.be.successWith({name: 'Random'});
});
});
});
```
## Failure
- `failure`
- `failureWith`
### Usage:
```js
describe('failure', function() {
it('should fail', function(done) {
req.get('/users/1').end(function(err, res) {
if (err) {return done(err);}
res.should.be.failure;
res.should.be.failureWith({id: 'Unknown user.'});
});
});
});
```
## Error
- `error`
- `errorWith`
### Usage:
```js
describe('errors', function() {
it('should error', function(done) {
req.get('/users/1').end(function(err, res) {
if (err) {return done(err);}
res.should.be.error;
res.should.be.errorWith('Server error.');
res.should.be.errorWith({
code: 500,
message: 'Server error.',
data: {power_level: 9001}
});
});
});
});
```