Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: expect(locator).toHaveCount should wait (#8901)
Dmitry Gozman6c41ad33294a
diff --git a/tests/playwright-test/playwright.expect.misc.spec.ts b/tests/playwright-test/playwright.expect.misc.spec.tsindex f6d8408c50..faf3a0df6f 100644--- a/tests/playwright-test/playwright.expect.misc.spec.ts+++ b/tests/playwright-test/playwright.expect.misc.spec.ts@@ -23,9 +23,15 @@ test('should support toHaveCount', async ({ runInlineTest }) => {const { test } = pwt;test('pass', async ({ page }) => {- await page.setContent('<select><option>One</option><option>Two</option></select>');+ await page.setContent('<select><option>One</option></select>');const locator = page.locator('option');- await expect(locator).toHaveCount(2);+ let done = false;+ const promise = expect(locator).toHaveCount(2).then(() => { done = true; });+ await page.waitForTimeout(1000);+ expect(done).toBe(false);+ await page.setContent('<select><option>One</option><option>Two</option></select>');+ await promise;+ expect(done).toBe(true);});`,}, { workers: 1 });