Я продолжаю получать ошибку в методе 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. свойство ('username', 'User1'); '? Можем ли мы отправить как 'res.send ({имя пользователя: 'User1'})' или 'res.render ('home', {имя пользователя: 'User1'})' в реальной функции? –