Run dockerized Chromium or Firefox in headless remote debugging mode and return browserWSEndpoint
needed for puppeteer.connect()
.
$ yarn add xrom
type TRunBrowserOptions = {
browser: 'chromium' | 'firefox',
version: string,
port?: number,
fontsDir?: string,
mountVolumes?: {
from: string,
to: string,
}[],
cpus?: number,
cpusetCpus?: number[]
}
type TRunBrowserResult = {
browserWSEndpoint: string,
closeBrowser: () => Promise<void>,
}
runBrowser(options: TRunBrowserOptions) => Promise<TRunBrowserResult>
import { runBrowser } from 'xrom'
import puppeteer from 'puppeteer-core'
const { browserWSEndpoint } = await runBrowser({ browser: 'chromium' })
const browser = await puppeteer.connect({ browserWSEndpoint })