Mocha Tdd Cheat Sheet

From WikiOD

Here is the cheatsheat of Mocha Tdd and basic guide on how to use Mocha Tdd

TDD[edit | edit source]

mocha.setup('tdd');

suite('something', function() {
  setup(function() {
  });

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

  teardown(function() {
  });
});

Async[edit | edit source]

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

Chai: Expect[edit | edit source]

var expect = chai.expect;

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

See also[edit | edit source]

Credit:rstacruz