You need to enable JavaScript to run this app. CircleCI中配合Cypress orb使用时Percy未运行问题咨询
优惠活动
大模型
产品
解决方案
定价
更多

CircleCI中配合Cypress orb使用时Percy未运行问题咨询

问题核心原因

你本地可正常运行的percy exec -- cypress run命令本质是先启动Percy代理进程,再运行Cypress测试,测试里的快照指令会把数据传给代理再上传到Percy服务。你当前的CircleCI配置中Cypress orb直接调用了默认的cypress run命令,没有启动Percy代理,所以测试运行时会提示"Percy not running",Percy控制台的构建因为长时间收不到快照数据会标记为失败。

修复方案

修改CircleCI配置,给cypress/run job新增command参数,自定义执行套了Percy包装的Cypress命令即可,修改后的完整配置参考如下:

version: 2.1
orbs:
  node: circleci/node@4.5.1
  cypress: cypress-io/cypress@1.28.0
  slack: circleci/slack@4.4.2
  percy: percy/agent@0.1.3
  

workflows:
  version: 2
  commit-workflow:
    jobs:
      - cypress/run:
          name: Smoke Tests
          record: true
          store_artifacts: true  
          spec: cypress/integration/E2E/*
          # 新增自定义执行命令,替换默认的cypress run
          command: percy exec -- cypress run
          post-steps:
            - store_test_results:
                path: test-results
            - slack/notify:
                channel: general
                event: fail
                template: basic_fail_1
                mentions: '@Jac'
            - slack/notify:
                channel: general
                event: pass
                template: basic_success_1
                mentions: '@Jac'   
      # 若使用新版Percy SDK,可删除percy/finalize_all job,命令执行完成后会自动结束构建
      # - percy/finalize_all:
      #      requires:
      #        - Smoke Tests

额外检查项

  • 确认已在CircleCI项目的环境变量配置中添加了PERCY_TOKEN,该token可从Percy对应项目的设置页获取,缺少该参数会导致快照无法上传到对应项目。
  • 若运行时提示percy命令不存在,确认项目依赖中已安装@percy/cypress包,或在Cypress测试执行前添加percy-cli的安装步骤。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.14 16:15:04