Skip to content

Instantly share code, notes, and snippets.

@colinmeinke
Last active December 19, 2015 07:09
Show Gist options
  • Save colinmeinke/5916573 to your computer and use it in GitHub Desktop.
Save colinmeinke/5916573 to your computer and use it in GitHub Desktop.
Mocha Chai unit testing
// Load the assertion library
var chai = require('chai'),
should = chai.should();
describe('Hello world example', function() {
// This should pass
it('should be a string', function() {
var hello_world = 'hello world';
hello_world.should.be.a('string');
});
// This should pass
it('should have length of 11', function() {
var hello_world = 'hello world';
hello_world.should.have.length(11);
});
// This should fail
it('should equal "not even close"', function() {
var hello_world = 'hello world';
hello_world.should.equal('not even close');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment