量角器中的“ defaultTimeoutInterval”何时重置?

阿什什·兰詹(Ashish ranjan)

我正在ProtractorJasmine一起为Angular2应用程序编写e2e测试用例

我有两个问题:

1.关于DefaultTimeoutInterval

我的理解是,每当一个诺言开始时,即开始倒计时,如果诺言未在中指定的defaultTimeoutInterval时间内完成protractor.conf.js,则量角器将在控制台上导致错误。但是,如果承诺在内完成,defaultTimeoutInterval则倒计时将重置并在下一个承诺开始时开始。

如果上述说法是正确的,我想澄清一下,如果我有一连串的诺言,那么什么时候倒计时会重置?在链中的所有承诺完成之后还是每个承诺完成之后?

如果倒计时在链中的所有承诺完成后重新设置,则正确的做法是将这些承诺作为it()/fit() blocks?的直接子项

我下面有一个示例代码来解释我要问的更多信息。

it("when does protractor's default timeout interval gets reset?", () => {

expect("a single promise here").toBe('something');      // I believe, after the promise inside the expect block finishes, the defaultTimeoutInterval should Reset.

// what happens if I have a chain of promises, like below?
// whether the defaultTimeoutInterval resets after every single promise inside the method `validateSuccessAlert()` and then the chained promises are finsihed?
// or will it reset on completion of every single promise?
PO.validateSuccessAlert('a method which has chained promises inside itself, returns a promise').then(() => {
    browser.waitForAngularEnabled(false).then(() => {
        PO.getEmailActivationLink('xxxxxx').then((activationCode) => {
            PO.openNewTab(activationCode).then(() => {
                PO.switchToTab(1).then(() => {
                    expect(PO.isVisible(element(by.css('.activateMailBox h3 small')))).toBeTruthy();
                    expect(element(by.css('.activateMailBox h3 small')).getText()).toBe('Congratulations!!');
                    expect(PO.isNotVisible(PO.getButtonByText('Proceed')));
                    PO.switchToTab(0);
                    browser.waitForAngularEnabled(true);                        // Re-enable the angular wait
                })
            })
        });
    });
})

})

2.关于allScriptsTimeout

我真的不明白,这很重要:每个文件中有一个规范?如果您也可以对此做一点解释,那将是很棒的。

Xotabu4

1)defaultTimeoutInterval是从茉莉花超时,每个it都不会使测试永久或非常长地运行-http: //www.protractortest.org/#/timeouts#timeouts-from-jasmine

将其设置为您认为it不应超过的某个默认值使用以下语法覆盖测试是否将比默认超时运行少得多或更多:

describe('Some feature', function () {

   it('can be really slow', function () {

   }, 5 * 60 * 1000) // 5 minutes

   it('can be really fast', function () {

   }, 5000) //5 seconds
}) 

2)allScriptsTimeout是量角器中每个EACH异步命令的超时时间,不会执行太长时间。

http://www.protractortest.org/#/timeouts#timeouts-from-webdriver

我通常不将其设置为超过10秒,以免使每个命令(如.sendKeys()、. click()等)占用大量时间。有时,当您在网格中运行或执行一些长命令(如巨大的.executeScript()等)时,有必要增加它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章