chai-jsend
v2.0.0
Published
Chai plugin for asserting JSend responses.
Downloads
3
Readme
chai-jsend
Chai plugin for asserting JSend responses.
Installation
npm install --save-dev chai-jsend
Assertions
Success
success
successWith
Usage:
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:
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:
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}
});
});
});
});