如何在Mocha中增加单个测试用例的超时 [英] How to increase timeout for a single test case in mocha

查看:72
本文介绍了如何在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);

这篇关于如何在Mocha中增加单个测试用例的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆