You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Monocart-reporter@owner标签无法关联至Playwright测试求助

问题:Playwright 结合 monocart-reporter 无法显示@owner标签

我使用Playwright执行端到端(E2E)测试,已安装monocart-reporter,希望为每个测试添加@owner标签,以便特定测试失败时能向对应负责人发送邮件。但按照文档操作后,@owner标签完全无法生效——monocart-reporter本身可以正常生成报告、显示失败信息,但报告里完全看不到owner相关内容。

我的Playwright配置

export function createConfig(options: ICreatePlaywrightConfig): PlaywrightTestConfig {
 ...(其他信息)....
      reporter: [
          ['monocart-reporter', {
              name: "My Test Report",
              outputFile: './test-results/report.html',
              embedAnnotationsAsProperties: true,

              // 自定义列
              columns: (defaultColumns) => {

                  // 在默认列前插入自定义列
                  const index = defaultColumns.findIndex((column) => column.id === 'duration');
                  defaultColumns.splice(index, 0, {
                      // 在报告中定义列
                      id: 'owner',
                      name: 'Owner',
                      align: 'center',
                      searchable: true,
                      styleMap: {
                          'font-weight': 'normal'
                      }
                  }, {
                      // JIRA链接列
                      id: 'jira',
                      name: 'JIRA Key',
                      width: 100,
                      searchable: true,
                      styleMap: 'font-weight:normal;',
                      formatter: (v, rowItem, columnItem) => {
                          const key = rowItem[columnItem.id];
                          return `<a href="https://your-jira-url/${key}" target="_blank">${v}</a>`;
                      }
                  });

              }
          }]
      ]

  };
  return config;
}

测试文件代码(test-name.spec.ts)

import { test, expect } from "@playwright/test";
import { goToPage, waitForSuccessApi } from "../../common/testUtils";
import { customReporter, addWorkItem } from "../../common/custom-reporter";  // hackathon
import type { TestResult } from '@playwright/test/reporter';

/*
 * @owner Kevin
 * @jira MCR-16888
 */
test.describe("HomePage", () => {
    // @owner Steve
    test("should load the homepage with a user id", async ({ page }) => {
        // @owner Steve
        await goToPage(page, "/mainpage");
        await page.locator("'Search using a User Id'").waitFor();
        await expect(page.locator('h2:has-text("Welcome to HomePage")')).toBeVisible();
    });

});

已尝试的标签位置

我尝试在以下位置添加@owner标签,均未生效:

  • test.describe上方的多行注释中
  • test用例定义前的单行注释中
  • 测试函数内部的单行注释中

报告截图

测试报告截图

内容的提问来源于stack exchange,提问作者SomeoneLearning17

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 23:33:31