使用带量角器的摩卡无法通过超时测试

Unable to fail the test by timeout using the mocha with protractor

本文关键字:超时 测试 摩卡 量角器      更新时间:2024-03-17

我在mocha网站上找到了,然后我们可以设置它阻塞的超时,但看起来它对我不起作用。

describe('something', function () {
    this.timeout(500);
    it('should take less than 500', function (done) {
        setTimeout(done, 500);
        browser.get('#/dashboard');
    });
})

运行结果:

something
  √ should take less than 500 <9849>

是否可以获得实际的测试超时并进行比较?或者我应该使用expect()测试失败?

感谢您提前提出任何想法。

我在导出中发现了问题。config:

  mochaOpts: {
    reporter: 'good-mocha-html-reporter',
    slow: 5000,
    enableTimeouts: true
  }
};

enableTimeouts处于false状态。

您还可以为每个it设置不同的超时,这些超时将覆盖exports.config值,如下所示-

it('should take less than 500', function (done) { setTimeout(done, 500); browser.get('#/dashboard'); },500);