2
第一個beforeEach
清除了用戶集合......它對第一組測試(#save()描述)適用,但不適用於第二個描述(「#find()」)。爲什麼beforeEach不能在mocha的第二個describe()語句中運行?
describe('User', function(){
beforeEach(function(done){
//clear out db
User.remove(done);
});
describe('#save()', function(){
beforeEach(function(done){
user = new User(fakeUser);
done();
});
it('should have username property', function(done){
});
it('should not save if username is not present', function(done){
});
});
describe('#find()', function(){
beforeEach(function(done){
user = new User(fakeUser);
user.save(function(err, user){
done();
});
});
it('should find user by email', function(done){
});
it('should find user by username', function(done){
});
});
});
第一個beforeEac
h指的是什麼?我認爲它爲每個小孩運行describe
,但顯然不是。