테스트를 실행할 때 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' 속성을 설정하는 방법은 다음과 같습니다 당신이 달성하려고하는 무엇을 작성합니다
방법이다. 속성 ('username', 'User1'); 실제 res.send ({username : 'User1'})'또는'res.render ('home', {username : 'User1'})'로 보낼 수 있습니까? 나는이 테스트를 실행하면 –