test: expect(locator).toHaveCount should wait (#8901)

This commit is contained in:
Dmitry Gozman 2021-09-13 17:06:19 -07:00 committed by GitHub
parent 478a7bcc90
commit 6c41ad3329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 });