का उपयोग करके सभी परीक्षणों के बाद डेटाबेस और बंद कनेक्शन को हटाने के लिए, मैं यह पता लगाने की कोशिश कर रहा हूं कि डेटाबेस को हटाने के लिए फ़ंक्शन कहां रखना है और सभी परीक्षणों के बाद कनेक्शन बंद करना है।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();
});
});
});
});
कुछ भी नहीं काम करने के लिए लगता है। मैं त्रुटि मिलती है: 2000ms की टाइमआउट को पार कर
वास्तव में, मैं इस त्रुटि 2 बार परीक्षण कर चलाने के: '✖ 5 में से 1 परीक्षण असफल: 1) उपयोगकर्ता #save() हुक" प्रत्येक से पहले ": त्रुटि: का समय समाप्त 2000ms ' – chovy
@chovy से अधिक है यह आपको प्रत्येक "हुक *" से पहले' * 'दिशा दे रहा है। इसलिए, आपके पास' पहले से 'है जो परिष्करण नहीं कर रहा है, शायद इसलिए कि आपने कॉलबैक स्वीकार करने के लिए तर्क का नाम दिया है लेकिन तो इसे कॉल नहीं कर रहे हैं। मोचा के साथ, आपको या तो इसे अनाम (0 तर्क) - 'फ़ंक्शन() {...} '- या इसे नाम दें और इसे कॉल करें -' फ़ंक्शन (किया गया) {किया गया();} ' –
अब मुझे एक अलग त्रुटि मिल रही है: https://gist.github.com/a821 7751061ad6e738b9 1) "सब के बाद" हुक: त्रुटि: 2000ms का टाइमआउट – chovy