Vue Cypress和Gitlab CI/CD

4

我目前正在尝试将我的E2E测试运行在Gitlab的CI/CD平台上。

目前我的问题是,我无法同时运行开发服务器和Cypress,以便进行E2E测试。

这是我当前的.gitlab-ci.yml文件:

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
2个回答

1
Cypress的官方GitHub页面中,有一个示例.gitlab-ci.yml用于在持续集成中运行Cypress
它使用命令npm run start:ci&在后台运行开发服务器。

因此,你的.gitlab-ci.yml可能看起来像这样:

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


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接