Skip to content

Instantly share code, notes, and snippets.

@Xotabu4
Created December 4, 2024 13:38
Show Gist options
  • Save Xotabu4/12deb64cb99f993edd9237da545da1b7 to your computer and use it in GitHub Desktop.
Save Xotabu4/12deb64cb99f993edd9237da545da1b7 to your computer and use it in GitHub Desktop.
/**
* 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