replay-playwright
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesereplay-playwright
replay-playwright
Description: Use when the user wants to set up Replay for Playwright tests, configure the Replay Playwright plugin, or run Playwright tests with the Replay Browser. Examples: "set up replay for my playwright tests", "record my playwright tests", "configure replay playwright plugin", "run tests with replay browser".
Instructions:
You are helping the user set up and run Playwright tests with the Replay Browser. Here is the complete reference:
说明: 当用户想要为Playwright测试设置Replay、配置Replay Playwright插件,或使用Replay Browser运行Playwright测试时使用。示例:"为我的Playwright测试设置Replay"、"录制我的Playwright测试"、"配置Replay Playwright插件"、"使用Replay Browser运行测试"。
操作指南:
您正在帮助用户使用Replay Browser设置并运行Playwright测试。以下是完整参考:
Installation
安装
1. Install the Replay Playwright plugin
1. 安装Replay Playwright插件
sh
npm install --save-dev @replayio/playwrightsh
npm install --save-dev @replayio/playwrightor
or
yarn add --dev @replayio/playwright
yarn add --dev @replayio/playwright
or
or
pnpm add --save-dev @replayio/playwright
pnpm add --save-dev @replayio/playwright
or
or
bun add --dev @replayio/playwright
undefinedbun add --dev @replayio/playwright
undefined2. Install the Replay Browser
2. 安装Replay Browser
sh
npx replayio installsh
npx replayio installAuthentication
身份验证
Create a Test Suite Team at https://app.replay.io/team/new/tests to generate an API key.
Store the API key using one of these methods:
- file (recommended): Add
.envto yourREPLAY_API_KEY=<your_api_key>file and use the dotenv package to load it..env - macOS/Linux:
export REPLAY_API_KEY=<your_api_key> - Windows:
set REPLAY_API_KEY=<your_api_key>
通过以下方式之一存储API密钥:
- 文件(推荐):在
.env文件中添加.env,并使用dotenv包加载它。REPLAY_API_KEY=<您的API密钥> - macOS/Linux:
export REPLAY_API_KEY=<您的API密钥> - Windows:
set REPLAY_API_KEY=<您的API密钥>
Configuration
配置
Update to use the Replay reporter and Replay Chromium browser:
playwright.config.tstypescript
import { replayReporter, devices as replayDevices } from "@replayio/playwright";
const config: PlaywrightTestConfig = {
reporter: [
replayReporter({
apiKey: process.env.REPLAY_API_KEY,
upload: true,
}),
["line"],
],
projects: [
{
name: "replay-chromium",
use: { ...replayDevices["Replay Chromium"] },
},
],
};Key configuration details:
- handles uploading recordings after test runs
replayReporter - automatically uploads recordings when tests finish
upload: true - The project uses the Replay Browser to capture recordings
replay-chromium - You can keep existing projects alongside for regular test runs
replay-chromium
更新以使用Replay报告器和Replay Chromium浏览器:
playwright.config.tstypescript
import { replayReporter, devices as replayDevices } from "@replayio/playwright";
const config: PlaywrightTestConfig = {
reporter: [
replayReporter({
apiKey: process.env.REPLAY_API_KEY,
upload: true,
}),
["line"],
],
projects: [
{
name: "replay-chromium",
use: { ...replayDevices["Replay Chromium"] },
},
],
};关键配置细节:
- 负责在测试运行后上传录制内容
replayReporter - 会在测试完成后自动上传录制内容
upload: true - 项目使用Replay Browser捕获录制内容
replay-chromium - 您可以保留现有项目,与项目并存以进行常规测试运行
replay-chromium
Running Tests
运行测试
Run Playwright tests with the Replay Browser:
sh
npx playwright test --project replay-chromiumRecordings are automatically uploaded when is set in the reporter config.
upload: true使用Replay Browser运行Playwright测试:
sh
npx playwright test --project replay-chromium当报告器配置中设置时,录制内容会自动上传。
upload: trueCore Workflow
核心工作流
Set up Replay for an existing Playwright project:
- Install the plugin:
npm install --save-dev @replayio/playwright - Install the browser:
npx replayio install - Update with the Replay reporter and project
playwright.config.ts - Set the environment variable
REPLAY_API_KEY - Run tests:
npx playwright test --project replay-chromium
When modifying the user's :
playwright.config.ts- Preserve existing projects and reporters — add the Replay project and reporter alongside them
- Import and
replayReporterfromdevices as replayDevices@replayio/playwright - If the config uses , add the Replay project to the existing
defineConfigarrayprojects - If the config already has reporters, append to the existing array
replayReporter
为现有Playwright项目设置Replay:
- 安装插件:
npm install --save-dev @replayio/playwright - 安装浏览器:
npx replayio install - 更新,添加Replay报告器和项目
playwright.config.ts - 设置环境变量
REPLAY_API_KEY - 运行测试:
npx playwright test --project replay-chromium
修改用户的时:
playwright.config.ts- 保留现有项目和报告器——将Replay项目和报告器添加到其中
- 从导入
@replayio/playwright和replayReporterdevices as replayDevices - 如果配置使用,将Replay项目添加到现有的
defineConfig数组中projects - 如果配置已有报告器,将追加到现有数组中
replayReporter
Debugging your recorded application
调试录制的应用程序
Run Replay MCP Server to debug your recored application
to install the MCP server in Claude, run the following command:
claude --mcp-config "{
"mcpServers": {
"replay": {
"type": "http",
"url": "https://dispatch.replay.io/nut/mcp",
"headers": {
"Authorization": "${REPLAY_API_KEY}"
}
}
}
}"运行Replay MCP Server以调试录制的应用程序
要在Claude中安装MCP服务器,请运行以下命令:
claude --mcp-config "{
"mcpServers": {
"replay": {
"type": "http",
"url": "https://dispatch.replay.io/nut/mcp",
"headers": {
"Authorization": "${REPLAY_API_KEY}"
}
}
}
}"