すべてのテストを実行した後、データベースを削除する関数をどこに置くかを調べようとしています。ここでどこのデータベースを削除し、mochaを使ったすべてのテストの後に接続を終了する
は私のネストされたテストです:
//db.connection.db.dropDatabase();
//db.connection.close();
describe('User', function(){
beforeEach(function(done){
});
after(function(done){
});
describe('#save()', function(){
beforeEach(function(done){
});
it('should have username property', function(done){
user.save(function(err, user){
done();
});
});
// now try a negative test
it('should not save if username is not present', function(done){
user.save(function(err, user){
done();
});
});
});
describe('#find()', function(){
beforeEach(function(done){
user.save(function(err, user){
done();
});
});
it('should find user by email', function(done){
User.findOne({email: fakeUser.email}, function(err, user){
done();
});
});
it('should find user by username', function(done){
User.findOne({username: fakeUser.username}, function(err, user){
done();
});
});
});
});
何も動いていないようにみえ。私はエラーを取得:2000ミリ秒のタイムアウトが
2000msを超えました – chovy
@ chovyコールバックを受け入れるために引数に名前を付けたのではないかと思いますが、それぞれのフック*の前に '*'あなたはそれを無名(0引数) - 'function(){...}' - または名前をつけてそれを 'function(done){done ();} '。 –
別のエラーが発生しました:https://gist.github.com/a821 7751061ad6e738b9 1) "after all"フック: エラー:2000msのタイムアウトが – chovy