Skip to content

Commit 1e34f80

Browse files
test: use replay jest runner to add current test name to recording (vercel#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
1 parent c52cb5a commit 1e34f80

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const customJestConfig = {
2222
},
2323
}
2424

25+
if (process.env.RECORD_REPLAY) {
26+
customJestConfig.testRunner = '@replayio/jest/runner'
27+
}
28+
2529
// Check if the environment variable is set to enable test report,
2630
// Insert a reporter to generate a junit report to upload.
2731
//

test/lib/browsers/replay.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ export { quit } from './playwright'
55
export class Replay extends Playwright {
66
async launchBrowser(browserName: string, launchOptions: Record<string, any>) {
77
const browser: any = browserName === 'chrome' ? 'chromium' : browserName
8+
const executablePath = getExecutablePath(browser)
9+
10+
if (!executablePath) {
11+
throw new Error(`No replay.io executable for browser \`${browserName}\``)
12+
}
13+
814
return super.launchBrowser(browserName, {
915
...launchOptions,
10-
executablePath: getExecutablePath(browser) || undefined,
16+
executablePath,
1117
env: {
1218
...process.env,
19+
RECORD_ALL_CONTENT: 1,
1320
},
1421
})
1522
}

test/lib/next-webdriver.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export default async function webdriver(
9696
const { Selenium, quit } = await import('./browsers/selenium')
9797
CurrentInterface = Selenium
9898
browserQuit = quit
99-
} else if (process.env.RECORD_REPLAY === 'true') {
99+
} else if (
100+
process.env.RECORD_REPLAY === 'true' ||
101+
process.env.RECORD_REPLAY === '1'
102+
) {
100103
const { Replay, quit } = await require('./browsers/replay')
101104
CurrentInterface = Replay
102105
browserQuit = quit

0 commit comments

Comments
 (0)