![](/img/trans.png)
[英]Mocha Unit Test Timeout of 10000ms exceeded Error when using await Promise.all
[英]Mocha unit test: how to forcefully stop execution of test after timeout exceeded
我正在使用 mocha 運行單元測試,我想強制超時,如果 function 超過 30000,所以我設置了 this.timeout(30000);
為了驗證它的工作我在測試用例中放置了無限循環,即使超時超過測試也不會返回。 我希望這個測試在超時后停止執行。
這是測試
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.