Last active
March 1, 2023 14:52
-
-
Save jkohlin/91fca6950fb968fe3950251de83fa7a4 to your computer and use it in GitHub Desktop.
a weird little promise wrapper around playwright event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function blockUntilEvent(page: Page, callback: (frame: Frame, resolve: any, reject: any) => Promise<void>) { | |
return await new Promise((resolve, reject) => | |
page.on('framenavigated', async (frame) => { | |
try { | |
await callback(frame, resolve, reject); | |
} catch (err) { | |
reject(err); | |
} | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment