Skip to content

Commit 4f27955

Browse files
committed
test(common): Add helper for waiting until web components ready
1 parent 1d67959 commit 4f27955

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/common/util.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ export async function sleep(ms = 1500) {
1616
});
1717
}
1818

19+
export async function webComponentsReady(driver: WebDriver) {
20+
const ready = async () => (await driver.executeScript("return window.WebComponents.ready")) as boolean;
21+
while (!await ready()) {
22+
await sleep(100);
23+
}
24+
}
25+
1926
export async function snapshot(t: TestContext, element: WebElement) {
2027
if (process.env.TRAVIS) {
21-
const ready = async () => (await element.getDriver().executeScript("return window.WebComponents.ready")) as boolean;
22-
while (!(await ready())) {
23-
await sleep(100);
24-
}
28+
await webComponentsReady(element.getDriver());
2529
}
2630

2731
t.snapshot(await element.getAttribute("outerHTML"));

0 commit comments

Comments
 (0)