# @currents/playwright 中文文档

规范地址：https://npmcn.com/package/%40currents/playwright/

版本：2\.7\.0
npm 元数据更新时间：2026-11-02T22:46:02.889Z
中文译文更新时间：2026-11-11T05:02:36.218Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40currents/playwright
原文对照：https://npmcn.com/package/%40currents/playwright/?lang=original
项目主页：https://currents.dev/
源码仓库：https://github.com/currents-dev/currents-playwright-changelog

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：446 kB，17 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.18\.1
- 运行依赖：33 个
- 首次发布：2022-11-18T21:20:37.413Z
- 最新版本发布：2026-11-02T22:46:02.706Z
- 近 30 天下载量：1690938（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：224（近 12 个月 42 个）

## 中文简介

[当前](https://currents.dev/playwright) 是Playwright最受欢迎和最先进的基于云的平台 - 调试,错误分析,实时分析,管弦乐等等

## 安装

```sh
npm install @currents/playwright
```

也可以使用：`pnpm add @currents/playwright`、`yarn add @currents/playwright`、`bun add @currents/playwright`

## README

# @ 当前/ playwright

[当前](https://currents.dev/playwright) 是Playwright最受欢迎和最先进的基于云的平台 - 调试,错误分析,实时分析,管弦乐等等

![](https://static.currents.dev/npm_package_banner.png)

[![npm version](https://img.shields.io/npm/v/@currents/playwright.svg)](https://www.npmjs.com/package/@currents/playwright) [![npm dm](https://img.shields.io/npm/dm/@currents/playwright.svg)](https://www.npmjs.com/package/@currents/playwright) [![npm dt](https://img.shields.io/npm/dt/@currents/playwright.svg)](https://www.npmjs.com/package/@currents/playwright)

[文档](https://docs.currents.dev/) | [当前](https://currents.dev/?utm_source=currents-playwright-readme)

## 关键特性

**实时测试分析与调试**

-   为可靠、高业绩报告实时输入测试结果
-   跟踪文件、视频、截图和控制台输出保存到云中
-   综合试验历史、趋势分析和碎片跟踪
-   错误洞察和常见故障模式检测

**集成和自动化**

-   GitHub 与内置的 PR 注释和详细错误报告集成
-   新建状态和故障警报通知和警报缺失
-   发布跟踪器集成以合作并扩展工作流程
-   REST API 和 HTTP Webhooks 用于自定义集成
-   IDE 扩展为以 AI 驱动的真知灼见排除出故障而不留下代码

**性能缩放( S)**

-   使用 Orchestration 的 CI Playwright 测试速度可达 40% - 优于本地 Playwright sharding
-   Git 信息的收集和与CI的联系
-   测试和光谱级别的历史和趋势浏览器
-   使用强大的动作引擎进行选择性测试执行,在苍蝇上跳过和隔离测试

**为AI和现代开发而建**

-   即时反馈的 IDE 扩展名
-   自动校正错误时使用 AI 进行校正
-   有效自动化的MCP(模式上下文协议)
-   立即开始调试 - 结果可以实时获取

**企业准备**

-   SOC2符合要求并受到主要公司的信任
-   监测测试套件性能,自动报告
-   针对各类组织的灵活、基于使用的计划

* * *

## 所需资源

-   节点JS 20+
-   剧作家 1.40.1+

## 安装

```sh
npm install @currents/playwright
```

## 启用痕迹、截图和视频

```js
use: {
  // ...
  trace: "retain-on-failure-and-retries",
  video: "retain-on-failure",
  screenshot: "on",
}
```

## 开始

**要把这个交给AI吗?** 将下面的提示复制到 Cursor, Claude, ChatGPT, 或您的编辑助理, 并让它为您连接基础.

```
Your task is to update Playwright setup to report test results to Currents.dev

1. Install "@currents/playwright" package:

- as a development dependency
- using the project's package manager (npm, pnpm, yarn, etc...)

2. Update the Playwright configuration file (playwright.config.ts|js|mjs):

  - enable traces, videos and screenshots by updating the "use" property, e.g.:

  use: {
    trace: "retain-on-failure-and-retries",
    video: "retain-on-failure",
    screenshot: "on",
  }

  - add Currents test reporter, keep any existing reporters. Example:

  // playwright.config.ts
  import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";
  import { currentsReporter } from "@currents/playwright";

  export default defineConfig({
    // ...
    reporter: [currentsReporter()], // add Currents reporter
  });

3. Create a new "currents.config.ts" file next to the existing playwright.config.ts|js|mjs file.

- use the same extension
- add the content below

import { CurrentsConfig } from "@currents/playwright";

const config: CurrentsConfig = {
  recordKey: process.env.CURRENTS_RECORD_KEY!,
  projectId: process.env.CURRENTS_PROJECT_ID!
};

export default config;
```

几分钟后向海流报告测试结果 头去 [获取启动指南](https://docs.currents.dev/getting-started/your-first-playwright-run) 用于逐步设置指令.

指南涵盖:

-   安装 `@currents/playwright`
-   在您的 Playwright 配置中添加当前记者
-   进行第一次测试

## 管弦乐 - 加速测试

管弦乐帮助在CI机器之间分配测试,以便平行执行,实现 **测试速度快至40%** 比起本地的 Playwright 硬化.

相较于固定的收缩,海流使用历史计时数据进行智能分布测试,减少了CI时间和成本.

学习更多在 [管弦乐设置指南](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration)。 。 。 .

## CI 整合

检查在流行的 CI 服务商中运行 Playwright 测试以及将结果记录到电流的示例寄存器和指南 :

-   [GitHub 动作](https://docs.currents.dev/getting-started/ci-setup/github-actions)
-   [GitLab CI 语录](https://docs.currents.dev/getting-started/ci-setup/gitlab)
-   [詹金斯(英语:](https://docs.currents.dev/getting-started/ci-setup/jenkins)
-   [圆CI](https://docs.currents.dev/getting-started/ci-setup/playwright-circleci)
-   [AWS 代码构建](https://docs.currents.dev/getting-started/ci-setup/playwright-aws-code-build)
-   [Azure 函数](https://docs.currents.dev/getting-started/ci-setup/playwright-azure-devops)

所有CI/CD实例见 [电流实例](https://github.com/currents-dev/currents-examples) 仓库.

## 文档

探索启动和掌握电流的全面指南:

-   [剧作家平行化 - 硬化和管弦乐](https://docs.currents.dev/guides/pw-parallelization)
-   [剧作家标签](https://docs.currents.dev/guides/playwright-tags)
-   [播放机组件测试](https://docs.currents.dev/guides/playwright-component-testing)
-   [测试状况和结果](https://docs.currents.dev/tests/test-status)
-   [记录密钥设置](https://docs.currents.dev/guides/record-key)
-   [CI 构建ID配置](https://docs.currents.dev/guides/ci-build-id)

访问 [dev 文档](https://docs.currents.dev/) 用于完整文件.

## 常见问题

### @currents/playwright 是什么？

当前 是Playwright最受欢迎和最先进的基于云的平台 - 调试,错误分析,实时分析,管弦乐等等

### 如何安装 @currents/playwright？

在项目目录运行 npm install @currents/playwright，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 pwc、pwc-p，可以用 npx pwc 直接运行。

### @currents/playwright 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @currents/playwright 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @currents/playwright 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=20\.18\.1。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @currents/playwright 可以商用吗？

@currents/playwright 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @currents/playwright 的下载量有多少？

根据 npm 官方下载统计，@currents/playwright 在 2026/10/11 – 2026/11/09 这 30 天内被下载 1,690,938 次，日均约 56,365 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @currents/playwright 还在维护吗？

最新版本 2\.7\.0 发布于 2026/11/03（8 天前）；至今共发布 224 个版本，其中过去 12 个月发布了 42 个；首次发布于 2022/11/19。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

