【发布时间】:2014-09-03 14:13:35
【问题描述】:
我在before() 中有一个用于清理数据库的回调函数。
before() 中的所有内容都保证在 it() 开始之前完成吗?
before(function(){
db.collection('user').remove({}, function(res){}); // is it guaranteed to finish before it()?
});
it('test spec', function(done){
// do the test
});
after(function(){
});
【问题讨论】:
-
这应该可以。您只需要确保从您的
before处理程序返回一个承诺。例如。before(function () { return db.collection...}
标签: javascript asynchronous mocha.js