@cyborgtests/reporter

中文文档
3.0.0发布于 2026/07/28MITTypeScriptCommonJS近 30 天下载 7.9万

上传到剧作家报告服务器的记者

中文使用文档
文档目录10 节
  1. 安装
  2. 基本配置
  3. 硬块
  4. 测试检疫特性
  5. 如何运作
  6. 启用测试检疫
  7. 这个 checkQuarantine 固定线
  8. 配置选项
  9. 测试执行期间发生的情况
  10. 解决问题

记者

上传结果到 Playwright 报告服务器的 Playwright 记者 - https://github.com/Cyborg Tests/playwright-reports-server 页面存档备份,存于互联网档案馆

安装

npm i -D @cyborgtests/reporter

基本配置

在你身边 playwright.config.ts 或者说 playwright.config.js数字 :

  reporter: [
    // blob reporter is required, produced zip would be uploaded
    ['blob', { outputFile: 'test-results/blob.zip' }],
    [
      '@cyborgtests/reporter',
      {
        // true by default. Use this if you need to skip this reporter for some cases (local executions for example)
        enabled: true,
        /**
         * Your server url
         * @see https://github.com/CyborgTests/playwright-reports-server
         */
        url: 'https://your server instance.com',
        // Set token if your server instance has authentication enabled
        token: '1234',
        // Timeout for reporter HTTP requests to finish, default 60000ms, increase if you have slow server and big requests.
        requestTimeout: 60000,
        // Relative path to your blob. Required.
        reportPath: 'test-results/blob.zip',
        // Any custom metadata to attach to this blob (strings)
        resultDetails: {
          branch: process.env.CI_COMMIT_BRANCH,
          foo: 'bar',
          bar: 'baz'
        },
        // Automatically trigger HTML report generation after tests finish. Shards supported. false by default
        triggerReportGeneration: false
      },
    ],
  ],

那就做你的测试 如果你看到 [ReporterPlaywrightReportsServer] 🎭 HTML Report is available at: ... - 您的blob结果已成功发送到服务器!

硬块

在所有硬盘完成后自动生成报告得到支持。 但你必须说明 testRun 财务报告和审定财务报表 triggerReportGeneration: true数字 :

  • 在记者配置通过中
resultDetails: {
  ...
  // testRun required, it should be same for all shards!
  testRun: 'my-awesome-test-run-12'
  ...
},
triggerReportGeneration: true

记者将当前硬度数和总硬度数传递给服务器, 在上传了所有硬度后 - 报告会由服务器生成, 用于此中的所有 blobs testRun

测试检疫特性

测试检疫功能允许您自动跳过从Playwright Reports Server UI直接被标记为不稳定或片面的测试. 这有助于防止不稳定的测试阻断你的CI/CD管道.

如何运作

  1. 在Playwright Reports服务器中,测试通过网络UI(分析页面)或自动(如果设置页面上指定)被标记为隔离
  2. 测试执行前,记者从服务器获取隔离测试列表
  3. 记者将此列表写入本地的 JSON 文件
  4. 在进行试验时,每次试验都要对照检疫清单进行
  5. 以存储在服务器中的原因自动跳过检疫测试

启用测试检疫

为了能够自动跳过隔离试验:

  1. 导入扩展 test 从记者包中固定
  2. 启用 skipQuarantinedTests 在记者配置中
  3. 使用扩展 test 在您的配置中设置
import { defineConfig } from '@playwright/test';
import { test } from '@cyborgtests/reporter';

export default defineConfig({
  reporter: [
    ['blob', { outputFile: 'test-results/blob.zip' }],
    [
      '@cyborgtests/reporter',
      {
        url: 'http://localhost:3000',
        reportPath: 'test-results/blob.zip',
        // Specify the project name to fetch quarantined tests for
        resultDetails: {
          project: 'my-project',
        },
        // Enable test quarantine
        skipQuarantinedTests: true,
        // Optional: Custom path for the quarantine file (default: './quarantine.json')
        quarantineFilePath: './quarantine.json',
      },
    ],
  ],
  // Use the extended test fixture that checks quarantine status
  test: test,
});

这个 checkQuarantine 固定线

记者输出扩展 test 包括一个 checkQuarantine 钩子负责检查测试是否隔离.

配置选项

选项类型默认说明
skipQuarantinedTests布尔false允许自动跳过隔离测试
quarantineFilePath字符串'./quarantine.json'隔离列表的存储路径

测试执行期间发生的情况

何时 skipQuarantinedTests 启用 :

  1. 测试开始前 (单位:千美元)onBegin:

    • 记者收集隔离检验 /api/tests?status=quarantined&project=<your_project>
    • 结果写入 quarantineFilePath
  2. 每次试验期间 (单位:千美元)checkQuarantine 固定线:

    • 固定读取隔离文件
    • 检查是否 testId 匹配任何隔离测试ID
    • 如果匹配则跳过测试
  3. 测试完成 (单位:千美元)onEnd:

    • 结果被上传到服务器
    • 如果 triggerReportGeneration 真实

解决问题

未找到警告的检疫文件 :

[checkQuarantinedTests] Quarantine file not found at ./quarantine.json, proceeding without skipping tests.

确保记者可以从服务器上获取隔离测试(检查网络和认证).

测试未跳过 :

  • 校验 skipQuarantinedTests: true 设定
  • 验证您正在使用扩展 test 固定线 : import { test } from '@cyborgtests/reporter'
  • 检查 project 内 resultDetails 匹配服务器中的工程名称, 如果您没有此工程 - 它可以跳过
  • 确保正确生成隔离文件

所有测试被跳过 :

  • 检查服务器的测试管理阈值是否配置得当
  • 验证测试在服务器 UI (分析页) 中被正确标记为隔离

版本与发布记录

@cyborgtests/reporter 共发布 1 个版本,首次发布于 2026/07/28;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.0latest2026/07/283 个月前

关于 @cyborgtests/reporter 的常见问题

@cyborgtests/reporter 是什么?

上传到剧作家报告服务器的记者

如何安装 @cyborgtests/reporter?

在项目目录运行 npm install @cyborgtests/reporter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@playwright/test(^1.59.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 playwright-reporter-cli,可以用 npx playwright-reporter-cli 直接运行。

@cyborgtests/reporter 支持 TypeScript 吗?

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

@cyborgtests/reporter 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cyborgtests/reporter 可以商用吗?

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

@cyborgtests/reporter 的下载量有多少?

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

@cyborgtests/reporter 还在维护吗?

最新版本 3.0.0 发布于 2026/07/28(3 个月前);至今共发布 1 个版本,其中过去 12 个月发布了 1 个;首次发布于 2026/07/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。