1
votes

I'm trying to configure Gitlab CI to make it work with Cypress. In general everything starts, Cypress works itself. The problem appears with Cypress Dashboard. Basically iy works - tests are recorded correctly. The only issue is, I wanna test my app on two browsers - Chrome and Firefox. Cypress records both browsers in two separate runs:

One run per one browser

I know that I can't run both of them in the same time. But I wanted to use grouping functionality (or something) to "merge" runs.

Another thing that suggests me that grouping both browsers in one run could be possible, is this filter in test results:

Tests results

This is my job definition:

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"

And package.json scripts:

{
   "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"
   }
}

I'm using $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHA key for grouping both browsers and groups are created but in separate runs.

I was also trying to set Run Completion Delay on cypress.io > Project > Settings > Parallelization to some high value like 1200. But that didn't help with my problem.

Alternatively in desperation, I tried to remove all the parallelization, but it works the same way...

1

1 Answers

1
votes

I don't know how I missed that, but I have just found out that there is something like --ci-build-id flag which solves my problem :)

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