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
This commit is contained in:
parent
c52cb5ad83
commit
1e34f80c91
3 changed files with 16 additions and 2 deletions
|
@ -22,6 +22,10 @@ const customJestConfig = {
|
|||
},
|
||||
}
|
||||
|
||||
if (process.env.RECORD_REPLAY) {
|
||||
customJestConfig.testRunner = '@replayio/jest/runner'
|
||||
}
|
||||
|
||||
// Check if the environment variable is set to enable test report,
|
||||
// Insert a reporter to generate a junit report to upload.
|
||||
//
|
||||
|
|
|
@ -5,11 +5,18 @@ 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: getExecutablePath(browser) || undefined,
|
||||
executablePath,
|
||||
env: {
|
||||
...process.env,
|
||||
RECORD_ALL_CONTENT: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -96,7 +96,10 @@ export default async function webdriver(
|
|||
const { Selenium, quit } = await import('./browsers/selenium')
|
||||
CurrentInterface = Selenium
|
||||
browserQuit = quit
|
||||
} else if (process.env.RECORD_REPLAY === 'true') {
|
||||
} else if (
|
||||
process.env.RECORD_REPLAY === 'true' ||
|
||||
process.env.RECORD_REPLAY === '1'
|
||||
) {
|
||||
const { Replay, quit } = await require('./browsers/replay')
|
||||
CurrentInterface = Replay
|
||||
browserQuit = quit
|
||||
|
|
Loading…
Reference in a new issue