rsnext/test/lib/browsers/replay.ts
Leah 1e34f80c91
test: use replay jest runner to add current test name to recording (#60438)
### What?

Adds the name of the test that's running when the browser is started to
the recording.

Also makes `RECORD_REPLAY=1` work without `run-tests.js`

Closes PACK-2206
2024-01-10 10:31:32 +01:00

23 lines
686 B
TypeScript

import { getExecutablePath } from '@replayio/playwright'
import { Playwright } from './playwright'
export { quit } from './playwright'
export class Replay extends Playwright {
async launchBrowser(browserName: string, launchOptions: Record<string, any>) {
const browser: any = browserName === 'chrome' ? 'chromium' : browserName
const executablePath = getExecutablePath(browser)
if (!executablePath) {
throw new Error(`No replay.io executable for browser \`${browserName}\``)
}
return super.launchBrowser(browserName, {
...launchOptions,
executablePath,
env: {
...process.env,
RECORD_ALL_CONTENT: 1,
},
})
}
}