I am trying to write a test case using mocha and mongoose. But the following snippet of code that i have written gives me the error "Todo "before each" hook: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test." I am unable to fing the issue. I am a beginner in node. can anyone please help me out on this issue. Thanks in advance.
var Todo = require('../models/Todo'),
should = require('Should');
describe('Todo', function(){
beforeEach(function(done){
faketodo = {
name : 'xyz',
completed : true,
note : "This is test note"
}
Todo.remove(done);
});
describe('#save()', function(){
var todo;
beforeEach(function(done){
console.log('before each todo entry');
todo = new Todo(faketodo);
console.log('before each todo exit');
done();
});
it('should have name property', function(done){
todo.save(function(err, todo){
should.not.exist(err);
todo.should.have.property('name', 'xyz');
done();
});
});
it('should not save if name is not present', function(done){
todo.name = '';
todo.save(function(err, todo){
should.exist(err);
should.not.exist(todo.name);
done();
});
});
});
});