diff --git a/jest.config.js b/jest.config.js index d269f86b57..f2f3609b8f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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. // diff --git a/test/lib/browsers/replay.ts b/test/lib/browsers/replay.ts index 8043efea1b..5e865fad86 100644 --- a/test/lib/browsers/replay.ts +++ b/test/lib/browsers/replay.ts @@ -5,11 +5,18 @@ export { quit } from './playwright' export class Replay extends Playwright { async launchBrowser(browserName: string, launchOptions: Record) { 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, }, }) } diff --git a/test/lib/next-webdriver.ts b/test/lib/next-webdriver.ts index cd0b7bc9e1..b9ff4ce2e3 100644 --- a/test/lib/next-webdriver.ts +++ b/test/lib/next-webdriver.ts @@ -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