test(elements): make e2e tests for elements docs examples even less flaky (#26726)

PR Close #26726
This commit is contained in:
George Kalpakas 2018-10-24 19:03:48 +03:00 committed by Matias Niemelä
parent 1880c9531f
commit 54ea10288e
1 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,10 @@ describe('Elements', () => {
browser.wait(EC.elementToBeClickable(elem), 5000);
elem.click();
};
const waitForText = (elem: ElementFinder) => {
// Waiting for the element to have some text, makes the tests less flaky.
browser.wait(async () => /\S/.test(await elem.getText()), 5000);
}
beforeEach(() => browser.get(''));
@ -33,6 +37,8 @@ describe('Elements', () => {
messageInput.sendKeys('Angular rocks!');
click(popupComponentButton);
waitForText(popupComponent);
expect(popupComponent.getText()).toContain('Popup: Angular rocks!');
});
@ -62,6 +68,8 @@ describe('Elements', () => {
messageInput.sendKeys('Angular rocks!');
click(popupElementButton);
waitForText(popupElement);
expect(popupElement.getText()).toContain('Popup: Angular rocks!');
});