From 54ea10288e483d31d85ee1787fe55ab545ee6b3e Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 24 Oct 2018 19:03:48 +0300 Subject: [PATCH] test(elements): make e2e tests for elements docs examples even less flaky (#26726) PR Close #26726 --- aio/content/examples/elements/e2e/src/app.e2e-spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aio/content/examples/elements/e2e/src/app.e2e-spec.ts b/aio/content/examples/elements/e2e/src/app.e2e-spec.ts index 647077e099..d939501a86 100644 --- a/aio/content/examples/elements/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/elements/e2e/src/app.e2e-spec.ts @@ -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!'); });