check-chai

0.0.1 • Public • Published

Check Chai

NPM version NPM downloads MIT License

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 or assert calls with chai in mocha (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

Credits

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i check-chai

Weekly Downloads

90

Version

0.0.1

License

MIT

Last publish

Collaborators

  • niftylettuce
  • titanism