# Mocha.js cheatsheet
The one-page guide to Mocha.js: usage, examples, links, snippets, and more.

This is Devhints.io cheatsheets — a collection of cheatsheets I've written.

# Mocha.js

### BDD

    mocha.setup('bdd');

    describe('something', function() {
      beforeEach(function() {
      });

      it('should work', function() {
      });
    });

### Async

    it('should save', function(done) {
      var user = new User();
      user.save(function(err) {
        if (err) throw err;
        done();
      });
    });

### Chai: Shoulds

    chai.should();

    foo.should.be.a('string');
    foo.should.equal('bar');
    foo.should.have.length(3);
    tea.should.have.property('flavors').with.length(3);

### See also

- Mocha TDD
- Mocha HTML
- Chai
- Sinon
- Sinon Chai

Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. Suggestions and corrections? Send them in. I'm Rico Sta. Cruz. Check out my Today I learned blog for more.