저는 모카를 테스트 주자로 사용하고 Chai는 어설 션과 시논을 사용합니다. 내가 sinon를 사용하는 데 문제 , 내가 PrestigeQuoteService.js에서 테스트 할 다음 함수는 여기스텁이 값을 반환하지 않습니다.
find: function (criteria) {
return PrestigeQuote.find(criteria)
.populate('client')
.populate('vehicle')
.populate('quoteLogs');
},
을 제기하고있는 것은, 나의 테스트 케이스 아직
describe('find()', function() {
describe('prestige quote found', function() {
before(function() {
sandbox = sinon.sandbox.create();
var mockChain = {
populate: function() {
return this;
}
};
sandbox
.stub(PrestigeQuote, 'find').returns(mockChain);
});
it('should return a particular quote', function (done) {
PrestigeQuoteService.find({id: 1}, function (err, result) {
result.should.exist;
done();
});
});
after(function() {
sandbox.restore();
});
});
});
나는이 오류가있다 심지어 done()을했다고 생각하고 기본적으로 값을 반환해야합니다.
Error: timeout of 10000ms exceeded. Ensure the done() callback is being called in this test.
그것이 내가 함수가 객체를 반환하지 않습니다 생각, 내가 시간이 문제라고 생각하지 않습니다 작동하지 않습니다, mockChain에서 수익을 추가하려고했지만 여전히 작동하지 않습니다. – user1493376