如何在Mocha中增加单个测试用例的超时
问题描述:
我正在测试用例中提交网络请求,但这有时会花费超过2秒(默认超时)的时间.
I'm submitting a network request in a test case, but this sometimes takes longer than 2 seconds (the default timeout).
如何增加单个测试用例的超时时间?
How do I increase the timeout for a single test case?
答
在这里您可以: http://mochajs .org/#test-level
it('accesses the network', function(done){
this.timeout(500);
[Put network code here, with done() in the callback]
})
对于箭头功能,请按以下方式使用:
For arrow function use as follows:
it('accesses the network', (done) => {
[Put network code here, with done() in the callback]
}).timeout(500);