UNPKG

@coinbase/onchaintestkit

Version:

End-to-end testing toolkit for blockchain applications, powered by Playwright

16 lines (15 loc) 642 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.connectToDapp = connectToDapp; // Poll until the page is closed (or timeout). Avoids waitForEvent('close') // which can hang indefinitely if MetaMask reuses the popup. async function waitForPageClose(page, timeout = 5000) { const deadline = Date.now() + timeout; while (Date.now() < deadline && !page.isClosed()) { await new Promise(r => setTimeout(r, 200)); } } async function connectToDapp(notificationPage) { await notificationPage.getByRole("button", { name: "Connect" }).click(); await waitForPageClose(notificationPage); }