I am having issues passing protractor tests. As far as it looks, the project is based on a default angular 5 application but with additional styles/templates/layouts/components. As as result, a default e2e test that comes with the angular does not pass. The protractor configuration looks identical to a default one.
The log tells:
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Test:
describe('angular App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
}, 100000);
});
Page:
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('.test-header')).getText();
}
}
I have done some debugging on the code itself. The navigation part executes successfully and navigates to the url but when it tries to resolve a promise from getText() the whole execution stops. Feels like it gets blocked.
Is there a way to find out what could be blocking the protractor execution or at least watch what kind of async tasks are being run whenever it tries to run a test?
Any other solutions to this?
I am pretty new to e2e tests, so any help would be appreciated. Thanks.
EDIT: Adding browser.waitForAngularEnabled(false) before browser.get('/') fixes the issue but I would think its just a temporary band-aid
itasasync, then shouldn't youawaiteach promise?await page.navigateTo();andexpect(await page.getParagraphText()).toEqual('Welcome to app');- cnishinaasynckeyword from the method signature. As you have understood I tried toawaitthePromiseexplicitly but all I could find out is that it gets stuck ongetText(). - DasBootPromiseexplicitly before returning the result, I have tried that. - DasBoot, 100000);. Try that again without thebrowser.waitForAngularEnabled(false)call. Disabling it will remove the synchronous behavior. I believe your tests are currently passing by luck and could become flaky. The 100000 is an override to the jasmine.DEFAULT_TIMEOUT_INTERVAL... for "Custom timeout for an async spec." Does this mean that adding it in requires you to calldone()? See jasmine.github.io/api/edge/global.html#it - cnishina