This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
docs/src/frontend/apps/e2e/__tests__/helpers.ts

22 lines
598 B
TypeScript
Raw Normal View History

import { Locator } from '@playwright/test';
export async function waitForElementCount(
locator: Locator,
count: number,
timeout: number,
) {
let elapsedTime = 0;
const interval = 200; // Check every 200 ms
while (elapsedTime < timeout) {
const currentCount = await locator.count();
if (currentCount >= count) {
return true;
}
await locator.page().waitForTimeout(interval); // Wait for the interval before checking again
elapsedTime += interval;
}
throw new Error(
`Timeout after ${timeout}ms waiting for element count to be at least ${count}`,
);
}