Starting Quasar development server in GitLab CI locks up

Viewed 105

I'm having some trouble running Cypress tests within our GitLab CI pipeline. As soon as I start the Quasar development server with yarn quasar dev it looks as if it is actually starting, but then it seems to be kind of locked up.

GitLab CI console output showing dev server start

This state was for like an hour before GitLab killed the job.

Here is the pipeline definition. Please note that this is a simplified version for the sake of this question.

.gitlab-ci.yml

---
variables:
  FF_USE_FASTZIP: "true"
  YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/yarn"
  CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/Cypress"

.cache_configuration:
  cache:
    key:
      files:
        - yarn.lock
    paths:
      - package.json
      - yarn.lock
      - .cache/
      - node_modules/
      - dist/spa/

stages:
  - test

# Install dependencies and start Quasar dev server
ui-chrome:
  stage: test
  image: cypress/browsers:node16.14.0-chrome99-ff97
  extends: .cache_configuration
  cache:
    policy: pull
  script:
    - yarn install --frozen-lockfile # this works
    - yarn quasar dev # this seems to work but causes the lock up
    - yarn cypress run # this does not work
  rules:
    - if: '$CI_COMMIT_TAG =~ /^\d+.\d+.\d+$/'
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_MERGE_REQUEST_IID && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
1 Answers

quasar dev is a non-ending process. Under normal conditions, you wouldn't want the development server to close itself. In this case, you want the development server to run while the Cypress tests are running, then to shut down after the tests are finished.

Quasar Cypress App Extension(AE) adds a few package scripts you can use. It uses start-server-and-test under the hood. So, you can either directly use the scripts the AE provides, update them, or read start-server-and-test and create your own.

Here is the command for yarn test:e2e:ci package script:

cross-env NODE_ENV=test start-test "quasar dev" http-get://localhost:8080 "cypress run"

So, you can replace the following in your code:

  script:
    - yarn install --frozen-lockfile # this works
    - yarn quasar dev # this seems to work but causes the lock up
    - yarn cypress run # this does not work

to

  script:
    - yarn install --frozen-lockfile
    - yarn test:e2e:ci
Related