Skip to content

Instantly share code, notes, and snippets.

@sorribas
Last active December 28, 2015 17:39
Show Gist options
  • Save sorribas/7537110 to your computer and use it in GitHub Desktop.
Save sorribas/7537110 to your computer and use it in GitHub Desktop.
beforeEach hook in mocha
// taken from http://visionmedia.github.io/mocha/
describe('Connection', function(){
var db = new Connection
, tobi = new User('tobi')
, loki = new User('loki')
, jane = new User('jane');
beforeEach(function(done){
db.clear(function(err){
if (err) return done(err);
db.save([tobi, loki, jane], done);
});
})
describe('#find()', function(){
it('respond with matching records', function(done){
db.find({ type: 'User' }, function(err, res){
if (err) return done(err);
res.should.have.length(3);
done();
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment