Skip to content

Instantly share code, notes, and snippets.

@davisford
Created December 17, 2012 20:15
Show Gist options
  • Select an option

  • Save davisford/4321730 to your computer and use it in GitHub Desktop.

Select an option

Save davisford/4321730 to your computer and use it in GitHub Desktop.
mocha.js + mongoosejs database test skeleton
var mongoose = require('mongoose');
mongoose.connection.on('error', function (err) {
console.log('mongoose err: ', err);
});
mongoose.connection.on('open', function () {
console.log('mongoose connection established');
});
describe('Foo', function () {
before(function (done) {
mongoose.connect('mongodb://localhost/test');
done();
});
after(function (done) {
mongoose.disconnect(function () {
console.log('disconnected');
done();
});
});
it('should test something', function (done) {
'one'.should.equal('one');
done();
});
it('should test something else ', function (done) {
'two'.should.equal('two');
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment