Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.
/ check-chai Public archive

✅ Adds chai helper function `chai.check` for asynchronous testing with multiple expect or assert statements

License

Notifications You must be signed in to change notification settings

ladjs/check-chai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

✅ Adds chai helper function `chai.check` for asynchronous testing with multiple expect or assert statements

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published