Cypress does not execute any more specs on the second run in our GitLab CI

Viewed 79

We have a docker based GitLab CI which runs Cypress tests on a Magento store.

Sometimes this tests fail - which can happen. If we now retry the cypress job, it just passes after a few seconds and obviously did not execute any of the tests.

What can be the reason?

This is a part of the .gitlab-ci.yml

.test-job:
    tags:
    - docker-example-dev
    before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    image: docker.example.de/example/docker-images/docker-compose:latest
    variables:
    GIT_STRATEGY: none
    GIT_CLONE_PATH: $CI_BUILDS_DIR/shop.example.com/test-$CI_COMMIT_REF_SLUG
    COMPOSE_CMD: docker-compose -f docker/docker-compose.review.yml -f docker/docker-compose.yml -f docker/docker-compose.cypress.yml
    COMPOSE_HOSTNAME: test-$CI_COMMIT_REF_SLUG
    COMPOSE_PROJECT_NAME: shopexamplecom_test_$CI_COMMIT_REF_SLUG
    CYPRESS_BASE_URL: https://test-$CI_COMMIT_REF_SLUG.shop.example.com.example.dev/
    CYPRESS_MAILHOG_HOST: shopexamplecom_test_${CI_COMMIT_REF_SLUG}_mailhog_1
    DATA_PATH_HOST: /var/review-test-deploy/shop.example.com/test_$CI_COMMIT_REF_SLUG
    REVIEW_APP_DOMAIN: test-$CI_COMMIT_REF_SLUG.shop.example.com.example.dev
    TEST_ENVIRONMENT_URL: https://test-$CI_COMMIT_REF_SLUG.shop.example.com.example.dev/
    only:
    - merge_requests
    except:
    - master
    - develop
    - master-from-live
    
    
    
test-cypress-chrome:
    extends: [ .test-job ]
    stage: test-frontend
    script:
    - $COMPOSE_CMD run cypress yarn cy2 run --browser chrome --record --key some-key --ci-build-id $CI_PIPELINE_ID --group chrome

This is the output on the second run:

================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        9.6.0                                                                          │
  │ Browser:        Chrome 99 (headless)                                                           │
  │ Node Version:   v16.14.0 (/usr/local/bin/node)                                                 │
  │ Specs:          16 found (luma/b2b/b2b.spec.js, luma/b2b/exampl-leads.spec.js, luma/b2b/dropsh │
  │                 ipping.spec.js, luma/b2b/examplestu.spec.js, luma/cart/cart.spec.js, luma/cart │
  │                 /minicart.spec.js, luma/checkout/checkout.spec.js, luma/homepage.spec.js, luma │
  │                 /products/category.spec...)                                                    │
  │ Params:         Tag: false, Group: chrome, Parallel: false                                     │
  │ Run URL:        https://cypress.example.dev/run/86c9ad1b5251420313f618a9f403211c               │
  │ Experiments:    experimentalSessionAndOrigin=true                                              │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
================================================================================
tput: unknown terminal "xterm   npm_config_loglevel warn   npm_config_unsafe_perm true"
  (Run Finished)
Done in 5.17s.

And this was the first run, which actually took around 15 minutes and failed (which is fine):

tput: unknown terminal "xterm   npm_config_loglevel warn   npm_config_unsafe_perm true"
================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        9.6.0                                                                          │
  │ Browser:        Chrome 99 (headless)                                                           │
  │ Node Version:   v16.14.0 (/usr/local/bin/node)                                                 │
  │ Specs:          16 found (luma/b2b/b2b.spec.js, luma/b2b/exampl-leads.spec.js, luma/b2b/dropsh │
  │                 ipping.spec.js, luma/b2b/examplestu.spec.js, luma/cart/cart.spec.js, luma/cart │
  │                 /minicart.spec.js, luma/checkout/checkout.spec.js, luma/homepage.spec.js, luma │
  │                 /products/category.spec...)                                                    │
  │ Params:         Tag: false, Group: chrome, Parallel: false                                     │
  │ Run URL:        https://cypress.example.dev/run/86c9ad1b5251420313f618a9f403211c               │
  │ Experiments:    experimentalSessionAndOrigin=true                                              │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                
  Running:  luma/b2b/b2b.spec.js                                                           (1 of 16)
launching browser chrome is headless? true
setting the browser window size to 3840 x 2160
  B2B Shop
    ✓ Should prompt logging in when accessing the page (6477ms)
    ✓ Should require a login when accessing a b2b product (2311ms)

Can the reason be that the run URL is the same? Can it not be reused?

1 Answers

We kind of found the reason, specifying the same --ci-build-id again seems to cause cypress to skip everything on the second run

Related