I am using Protractor along with Jasmine to write e2e test cases for an Angular2 app.
I have two questions:
1. About DefaultTimeoutInterval
I have an understanding that a countdown starts whenever a promise starts and if the promise doesn't get completed within the specified defaultTimeoutInterval in protractor.conf.js, protractor will result in an error on the console. But if the promise gets completed within the defaultTimeoutInterval then the countdown will be reset and would be started when the next promise starts.
If the above is true, I wanted to clarify, If I have a chain of promises then when does the countdown gets reset? After all the promises in the chain are completed or after each promise is completed?
If the countdown resets after all the promises in the chain is completed, then the right practice would be to have the promises as direct children of the it()/fit() blocks?
I have a sample code below to explain more what I am trying to ask.
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. About allScriptsTimeout
I really don't understand this, this counts for: one spec in each file? If you can explain a little about this too, it will be great.
1) defaultTimeoutInterval is a timeout from jasmine for each it to not make test run forever or very long - http://www.protractortest.org/#/timeouts#timeouts-from-jasmine
Set it to some default value that you believe your it should not exceed. Override if your test will run much less or more than your default timeout with this syntax:
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 is timeout for EACH async command in protractor, to not execute for too long.
http://www.protractortest.org/#/timeouts#timeouts-from-webdriver
I usually do not set it more than 10 seconds, to not make each command (like .sendKeys(), .click() etc ) to take to much time. Sometimes it is necessary to increase when you running in grid, or making some long commands like huge .executeScript() or so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With