在这里,我附上了我的代码,我正在通过完成回调并使用超级请求。因为我在使用request.end中的测试用例中使用断言/期望为什么我需要担心超时?我在这里犯了什么错误。如何避免摩卡测试用例超时?
it('should get battle results ', function(done) {
request(url)
.post('/compare?vf_id='+vf_id)
.set('access_token',access_token)
.send(battleInstance)
.end(function(err, res){ // why need timeout
if (err) return done(err);
console.log(JSON.stringify(res.body));
expect(res.body.status).to.deep.equal('SUCCESS');
done();
});
});
测试结果如下响应: 错误:超过2000ms的超时。确保在此测试中正在调用done()回调。
如果我正在使用mocha命令运行我的测试用例,那么它会显示此错误,而如果我正在运行测试mocha --timeout 15000
,则testcase正确传递。但我想避免超时,我该怎么做?
可能重复[更改默认超时为摩卡](http://stackoverflow.com/questions/23492043/change-default-timeout-for-mocha) – Louis