replay-cypress
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesereplay-cypress
replay-cypress
Description: Use when the user wants to set up Replay for recording Cypress tests, configure the Replay Cypress plugin, or run Cypress tests with the Replay browser. Examples: "set up replay for cypress", "record my cypress tests", "configure replay cypress plugin", "run cypress with replay".
Instructions:
You are helping the user set up and configure Replay for recording Cypress tests. Follow these steps in order.
说明: 当用户想要设置Replay以录制Cypress测试、配置Replay Cypress插件或使用Replay浏览器运行Cypress测试时使用。示例:"为Cypress设置Replay"、"录制我的Cypress测试"、"配置Replay Cypress插件"、"使用Replay运行Cypress"。
操作步骤:
你正在帮助用户设置并配置Replay以录制Cypress测试,请按以下顺序执行步骤。
Step 1: Create a Test Suite Team
步骤1:创建测试套件团队
Direct the user to visit https://app.replay.io/team/new/tests to create a test suite team. This automatically generates an API key needed for uploading recordings.
Step 2: Install the Replay Cypress Plugin
步骤2:安装Replay Cypress插件
Install the plugin as a dev dependency:
sh
npm install --save-dev @replayio/cypress将插件作为开发依赖安装:
sh
npm install --save-dev @replayio/cypressor
or
yarn add --dev @replayio/cypress
yarn add --dev @replayio/cypress
or
or
pnpm add --save-dev @replayio/cypress
pnpm add --save-dev @replayio/cypress
or
or
bun add --dev @replayio/cypress
undefinedbun add --dev @replayio/cypress
undefinedStep 3: Install the Replay Browser
步骤3:安装Replay浏览器
sh
npx replayio installThis installs the Replay Chromium browser required for recording.
sh
npx replayio install这会安装录制所需的Replay Chromium浏览器。
Step 4: Store the API Key
步骤4:存储API密钥
The API key must be available as the environment variable. Save it in a file at the project root:
REPLAY_API_KEY.envREPLAY_API_KEY=<your_api_key>Alternatively, export it directly:
sh
export REPLAY_API_KEY=<your_api_key>API密钥需要作为环境变量存在。将其保存在项目根目录的文件中:
REPLAY_API_KEY.envREPLAY_API_KEY=<your_api_key>或者直接导出:
sh
export REPLAY_API_KEY=<your_api_key>Step 5: Configure the Cypress Support File
步骤5:配置Cypress支持文件
Add the Replay support import to (or ):
cypress/support/e2e.jse2e.tsCommonJS:
js
require('@replayio/cypress/support')ESM:
js
import '@replayio/cypress/support'在(或)中添加Replay支持导入:
cypress/support/e2e.jse2e.tsCommonJS:
js
require('@replayio/cypress/support')ESM:
js
import '@replayio/cypress/support'Step 6: Configure cypress.config.js (or cypress.config.ts)
步骤6:配置cypress.config.js(或cypress.config.ts)
Add the Replay plugin to the Cypress config:
js
const { defineConfig } = require('cypress')
const { plugin: replayPlugin, wrapOn } = require('@replayio/cypress')
require('dotenv').config()
module.exports = defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
upload: true,
apiKey: process.env.REPLAY_API_KEY,
})
return config
},
},
})For TypeScript ():
cypress.config.tsts
import { defineConfig } from 'cypress'
import { plugin as replayPlugin, wrapOn } from '@replayio/cypress'
import 'dotenv/config'
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
upload: true,
apiKey: process.env.REPLAY_API_KEY,
})
return config
},
},
})在Cypress配置中添加Replay插件:
js
const { defineConfig } = require('cypress')
const { plugin: replayPlugin, wrapOn } = require('@replayio/cypress')
require('dotenv').config()
module.exports = defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
upload: true,
apiKey: process.env.REPLAY_API_KEY,
})
return config
},
},
})对于TypeScript():
cypress.config.tsts
import { defineConfig } from 'cypress'
import { plugin as replayPlugin, wrapOn } from '@replayio/cypress'
import 'dotenv/config'
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
upload: true,
apiKey: process.env.REPLAY_API_KEY,
})
return config
},
},
})Step 7: Run Tests with Replay
步骤7:使用Replay运行测试
sh
npx cypress run --browser replay-chromiumRecordings are automatically uploaded and a URL is provided for each recording to view in Replay DevTools.
sh
npx cypress run --browser replay-chromium录制内容会自动上传,并为每个录制提供一个URL,可在Replay DevTools中查看。
Important Notes
重要说明
- The option in the plugin config enables automatic upload after tests complete.
upload: true - The wrapper is required — it wraps the Cypress
wrapOnevent handler so Replay can hook into test lifecycle events.on - Cypress events (test starts, commands, assertions) appear in the Replay DevTools timeline.
- For CI/CD, set the as a secret environment variable in your CI provider.
REPLAY_API_KEY
- 插件配置中的选项可在测试完成后启用自动上传。
upload: true - 包装器是必需的——它包装Cypress的
wrapOn事件处理程序,以便Replay可以挂钩到测试生命周期事件。on - Cypress事件(测试启动、命令、断言)会显示在Replay DevTools时间轴中。
- 对于CI/CD,请在CI提供商中将设置为秘密环境变量。
REPLAY_API_KEY
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}"
}
}
}
}"