@coinbase/onchaintestkit
Version:
End-to-end testing toolkit for blockchain applications, powered by Playwright
20 lines (19 loc) • 835 B
TypeScript
import type { BrowserContext, Page } from "@playwright/test";
export interface ViewportSize {
width: number;
height: number;
}
/**
* Generic utility to wait for and configure a page by URL.
*
* Uses a dual strategy to handle the TOCTOU race condition where a page
* opens between the context.pages() check and the waitForEvent listener:
* 1. Check context.pages() for an existing matching page
* 2. If not found, race waitForEvent('page') against polling
*
* @param context - Browser context to search for pages
* @param pageUrl - Partial URL to match (e.g., 'notification.html')
* @param viewport - Optional viewport size
* @returns Promise that resolves to the found and configured page
*/
export declare function waitForPage(context: BrowserContext, pageUrl: string, viewport?: ViewportSize): Promise<Page>;