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

已集成GitHub Actions的Cypress项目如何接入Allure生成测试报表

可以实现,以下是完整配置步骤

1. 本地安装Cypress Allure适配依赖

  • 首先在项目中安装适配包和命令行工具:
    npm i -D @shelex/cypress-allure-plugin allure-commandline
  • 修改cypress.config.js配置文件,引入Allure插件:
const { defineConfig } = require('cypress')
const allureWriter = require('@shelex/cypress-allure-plugin/writer')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      allureWriter(on, config)
      return config
    }
  }
})
  • 在cypress/support/e2e.js中添加导入语句,启用运行时数据采集:
    import '@shelex/cypress-allure-plugin'

2. 修改GitHub Actions工作流配置

在你现有Cypress执行的工作流yaml文件中,调整测试执行步骤,新增报告生成逻辑:

  • 调整Cypress执行命令,开启Allure数据采集:
    npx cypress run --env allure=true
  • 测试执行完成后,生成静态Allure仪表盘报告:
    npx allure generate allure-results --clean -o allure-report
  • 如果需要持久化查看报告,可将生成的allure-report文件夹配置为工作流产物上传,或是直接部署到GitHub Pages,使用官方部署Action即可完成,无需额外第三方服务。

注意事项

  • 请在.gitignore文件中添加allure-results和allure-report目录,避免本地生成的临时报告文件提交到代码库
  • 首次配置可以先本地执行测试验证Allure结果生成正常,再推送代码到GitHub触发工作流验证

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 12:24:03