Created
December 4, 2024 13:38
-
-
Save Xotabu4/12deb64cb99f993edd9237da545da1b7 to your computer and use it in GitHub Desktop.
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
/** | |
* Dirty hack taken from: https://github.com/asambstack/playwright-lighthouse/blob/master/src/util.js#L26 | |
* It is needed to make Playwright Page to be compatible with Puppeteer Page. | |
* Lighthouse lib works only with Puppeer pages. | |
* @param page | |
* @returns | |
*/ | |
const patchPageObject = (page: Page) => { | |
page.target = function target() { | |
return { | |
async createCDPSession() { | |
const session = await page.context().newCDPSession(page); | |
session.connection = () => new events.EventEmitter(); | |
return session; | |
}, | |
}; | |
}; | |
return page; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment