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
Anthony LC 3098b9f4fc 🚀(app-impress) create the e2e app impress
Create the e2e app impress, it will be used
to test the app impress.
2024-04-02 16:39:17 +02:00

22 lines
598 B
TypeScript

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}`,
);
}