While Replay Test Suites is designed for debugging tests in CI, it can be helpful to record a test locally for additional debugging or when first getting set up.
Overview
When recording locally, there are some additional steps.
- If using Playwright, additional configuration is required for best performance
- Set
RECORD_REPLAY_API_KEY
as an environment variable locally
- Upload replays manually after recording using
@replayio/replay
Cypress
Tests can only be recorded when in
cypress run
mode. You cannot use Replay to record with cypress open
. No additional configuration is required to record Cypress tests locally, just use the run command as described in the Cypress run command section. To only run certain tests, use the
--spec
flag built into Cypress.javascriptRECORD_ALL_CONTENT=1 RECORD_REPLAY_METADATA_FILE=$(mktemp) cypress run --browser 'Replay Firefox'
Then, upload your replays.
Playwright
When recording locally with Playwright, configure Playwright to only use a single worker and increase the timeout if needed to allow for increased run time.
Config example:
javascriptimport { PlaywrightTestConfig, devices } from "@playwright/test"; import { devices as replayDevices } from "@replayio/playwright"; const inCI = !!process.env.CI; const config: PlaywrightTestConfig = { timeout: !inCI ? 30 * 1000 : 10 * 1000, workers: !inCI ? 1 : undefined, use: { baseURL: !inCI ? "http://localhost:3000" : undefined, launchOptions: { slowMo: inCI ? 0 : 500, }, }, projects: [ { name: "replay-firefox", use: { ...replayDevices["Replay Firefox"] as any }, }, { name: "replay-chromium", use: { ...replayDevices["Replay Chromium"] as any }, }, { name: "firefox", use: { ...devices["Desktop Firefox"] }, }, { name: "chromium", use: { ...devices["Desktop Chromium"] }, }, ], }; export default config;
Once configured, use the run command as described in Playwright run command section, using options available in Playwright to only run certain tests as needed.
Then, upload your replays.