1
moza를 사용하여 NodeJS 응용 프로그램을 테스트하고 있습니다. 첫 번째 테스트가 원활하게 실행되는 동안 두 번째 테스트가 실패합니다 (오류는 null과 같습니다). 두 테스트 모두 콜백 내에서 유효한 사용자를 얻었습니다 (둘 다 몽구스에서 동일한 ID를 가짐). 테스트는 분명히 데이터베이스 작업이 수행되기를 기다리지 않습니다. 내가 첫 번째 테스트의 콜백의 두 번째 테스트를 배치 할 때 NodeJS 테스트 데이터베이스 (Mocha 및 should.js 포함)
describe("User", function(){
before(function (done) {
// clear database
model.UserModel.collection.remove(done);
})
it("should save", function(done){
user1.save(function(error, user){
should.not.exist(error);
user.should.have.property("first_name", "Rainer");
done();
})
})
it("should not save duplicate user", function(done){
user1.save(function(error, user){
should.exist(error);
done();
})
})
})