जब मैं परीक्षण चलाता हूं तो मुझे save() विधि में कोई त्रुटि मिलती रहती है।मैं मोचा और मोंगोस के साथ कैसे उपयोग कर सकता हूं?
var User = require('../../models/user')
, should = require('should');
describe('User', function(){
describe('#save()', function(){
it('should save without error', function(done){
var user = new User({
username : 'User1'
, email : '[email protected]'
, password : 'foo'
});
user.save(function(err, user){
if (err) throw err;
it('should have a username', function(done){
user.should.have.property('username', 'User1');
done();
});
});
})
})
})
यहाँ त्रुटि है:
$ mocha test/unit/user.js
․
✖ 1 of 1 test failed:
1) User #save() should save without error:
Error: timeout of 2000ms exceeded
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runnable.js:1
61:14)
at Timer.list.ontimeout (timers.js:101:19)
कैसे हम 'वास्तविक समारोह से username' संपत्ति सेट कर सकते हैं ताकि हम' user.should.have में उपयोगकर्ता नाम संपत्ति मिलती है:
तरह से मैं ने लिखा है कि आप क्या हासिल करने की कोशिश कर रहे हैं इस प्रकार है। संपत्ति ('उपयोगकर्ता नाम', 'उपयोगकर्ता 1'); '? क्या हम वास्तविक res में 'res.send ({उपयोगकर्ता नाम:' उपयोगकर्ता 1 '}) 'या' res.render (' home ', {username:' user1 '}) के रूप में भेज सकते हैं? –