简体   繁体   中英

Vue Cypress and Gitlab CI/CD

I am currently trying to get my E2E tests running on Gitlab with their CI/CD platform.

My issue at the moment is that I cannot both my dev server and cypress to run at the same time so that the E2E tests can run.

Here is my current .gitlab-ci.yml file:

image: node

variables:
  npm_config_cache: "$CI_PROJECT_DIR/.npm"
  CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress"

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm
    - cache/Cypress
    - node_modules

stages:
  - setup
  - test

setup:
  stage: setup
  image: cypress/base:10
  script:
    - npm ci
    # check Cypress binary path and cached versions
    # useful to make sure we are not carrying around old versions
    - npx cypress cache path
    - npx cypress cache list

cypress:
  stage: test
  image: cypress/base:10
  script:
    # I need to start a dev server here in the background
    - cypress run --record --key <my_key> --parallel
  artifacts:
    when: always
    paths:
      - cypress/videos/**/*.mp4
      - cypress/screenshots/**/*.png
    expire_in: 7 day

In Cypress's official GitHub page , there is an example .gitlab-ci.yml for running Cypress in continuous integration .
It uses command npm run start:ci & for running dev server in the background.

So, your .gitlab-ci.yml might look like this:

⋮
cypress:
  image: cypress/base:10
  stage: test
  script:
    - npm run start:ci &      # start the server in the background
    - cypress run --record --key <my_key> --parallel
⋮

或者使用此实用程序启动服务器,等待 URL 响应,然后运行测试并关闭服务器https://github.com/bahmutov/start-server-and-test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM