【问题标题】:Recording multiple browsers in a single run in Cypress在 Cypress 中一次运行记录多个浏览器
【发布时间】:2020-08-05 12:49:28
【问题描述】:

我正在尝试配置 Gitlab CI 以使其与 Cypress 一起使用。一般来说,一切都开始了,赛普拉斯自己工作。问题出现在Cypress Dashboard。基本上我可以工作 - 测试被正确记录。唯一的问题是,我想在两种浏览器上测试我的应用程序——Chrome 和 Firefox。 Cypress 在两个单独的运行中记录两个浏览器:

我知道我can't run both of them in the same time。但我想使用分组功能(或其他东西)来“合并”runs

另一件事表明我可以在一次运行中对两个浏览器进行分组,这是测试结果中的过滤器:

这是我的工作定义:

End-To-End:
  stage: e2e
  parallel: 2
  artifacts:
    when: on_failure
    paths:
      - dist/cypress/apps/client/my-app-web-e2e/videos/**/*.mp4
      - dist/cypress/apps/client/my-app-web-e2e/screenshots/**/*.png
    expire_in: 7 days
  script:
    - yarn e2e:ci:chrome --record --key $CYPRESS_RECORD_KEY --group "$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA"
    - yarn e2e:ci:firefox --record --key $CYPRESS_RECORD_KEY --group "$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA"

还有package.json 脚本:

{
   "scripts": {
      "e2e:ci": "nx affected --target=e2e --runner=ci --base=remotes/origin/master --parallel --prod --headless",
      "e2e:ci:chrome": "yarn run e2e:ci --browser=chrome",
      "e2e:ci:firefox": "yarn run e2e:ci --browser=firefox"
   }
}

我使用$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA 键对浏览器和组进行分组,但在单独的runs 中创建。

我还尝试将cypress.io > Project > Settings > Parallelization 上的Run Completion Delay 设置为像1200 这样的高值。但这对我的问题没有帮助。

在绝望中,我试图删除所有并行化,但它的工作方式相同......

【问题讨论】:

    标签: gitlab gitlab-ci cypress


    【解决方案1】:

    我不知道我是怎么错过的,但我刚刚发现有类似--ci-build-id 标志的东西可以解决我的问题:)

    variables:
      CI_ID: "$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA"
    
    ...
    
    End-To-End:
      stage: e2e
      parallel: 2
      artifacts:
        when: on_failure
        paths:
          - dist/cypress/apps/client/my-app-web-e2e/videos/**/*.mp4
          - dist/cypress/apps/client/my-app-web-e2e/screenshots/**/*.png
        expire_in: 7 days
      script:
        - yarn e2e:ci:chrome --record --key $CYPRESS_RECORD_KEY --group Chrome --ci-build-id $CI_ID
        - yarn e2e:ci:firefox --record --key $CYPRESS_RECORD_KEY --group Firefox --ci-build-id $CI_ID
    

    【讨论】:

      猜你喜欢
      • 2018-11-02
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      相关资源
      最近更新 更多