1
私はモカをテストランナー、チャイをアサーションとシノンに使用しています。私は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