check-chai
v0.0.1
Published
Adds chai helper function `chai.check` for asynchronous testing with multiple expect or assert statements
Downloads
40
Readme
Check Chai
Adds chai helper function
chai.check
for asynchronous testing with multiple expect or assert statements.
This is a simple helper function to call a series of
expect
orassert
calls withchai
inmocha
(namely for use with asynchronous tests; based on http://stackoverflow.com/a/15208067)
I built this package while I was writing tests for https://github.com/niftylettuce/node-react-native-fetch-api.
npm install --save check-chai
var chai = require('chai');
var dirtyChai = require('dirty-chai');
var checkChai = require('check-chai');
var expect = chai.expect;
chai.use(dirtyChai);
chai.use(checkChai);
describe('test', function() {
it('should do something', function(done) {
// imagine you have some API call here
// and it returns (err, res, body)
var err = null;
var res = {};
var body = {};
chai.check(done, function() {
expect(err).to.be.a('null');
expect(res).to.be.an('object');
expect(body).to.be.an('object');
});
});
});
Contributors
- Nick Baugh [email protected]