[英]Mocha unit test: how to forcefully stop execution of test after timeout exceeded
I am running unit test using mocha, I want to forcefully timeout, if the function exceeds 30000, so I have set this.timeout(30000);我正在使用 mocha 运行单元测试,我想强制超时,如果 function 超过 30000,所以我设置了 this.timeout(30000);
to verify its working I put infinite loop inside test case, even timeout exceeds test doesn't return back.为了验证它的工作我在测试用例中放置了无限循环,即使超时超过测试也不会返回。 I want this test to stop executing after timeout.
我希望这个测试在超时后停止执行。
Here is the test这是测试
it('should forcefully timeout',function(done) {
this.timeout(30000);
while(1) {
for(var i = 0; i < 10000; i++) {
if( i % 2 == 0 ) {
console.log("here");
for(var i=0; i < 10000; i++) {
if( i % 2 == 0 ) {
console.log("here1");
}
}
}
}
}
done();
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.