cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.71k stars 3.16k forks source link

Xvfb needs to be installed to be able to run the bitbucket pipeline #14457

Closed hvaandres closed 3 years ago

hvaandres commented 3 years ago

Looking into previous tickets, it seems that has to be installed from the NPM libraries which I'm not sure why is asking me to install this since I can't run Sudo under the pipeline.

This is my output:

> installation_cypress@1.0.0 cy:run /opt/atlassian/pipelines/agent/build
> cypress run
It looks like this is your first time using Cypress: 6.2.1
[21:42:54]  Verifying Cypress can run /root/.cache/Cypress/6.2.1/Cypress [started]
[21:42:54]  Verifying Cypress can run /root/.cache/Cypress/6.2.1/Cypress [failed]
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 9.9)
Cypress Version: 6.2.1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! installation_cypress@1.0.0 cy:run: `cypress run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the installation_cypress@1.0.0 cy:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-01-07T21_42_54_586Z-debug.log
2021-01-07T21:42:54.598292177Z stdout P 

What we should do to solve this issue?

jennifer-shehane commented 3 years ago

Have you tried using our provided docker images https://github.com/cypress-io/cypress-docker-images? They have all system dependencies installed. Running Cypress requires these outside dependencies be installed before you can run it. https://on.cypress.io/continuous-integration#Advanced-setup Most people find docker images to be helpful since installing directly is difficult, as you mentioned.

There's also a blog showing setup for Bitbucket here that may be helpful: https://www.cypress.io/blog/2018/08/30/setting-up-bitbucket-pipelines-with-proper-caching-of-npm-and-cypress/#header

hvaandres commented 3 years ago

Now, I solved this issue by using this configuration:

package.json:

"scripts": {

 "jira:chrome": "cypress run --group 1x-chrome --record --headless --browser chrome",

  "jira:firefox": "cypress run --group 1x-firefox --record --headless --browser firefox",

  "jira:electron": "cypress run --group 1x-electron --record  --headless --browser electron"
}

bitbucket-pipelines.yaml:


image: cypress/included:6.2.1
options:
  max-time: 10

# job definition cross-browser testing
jira-chrome: &jira-chrome
  name: JIRA Chrome tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:chrome -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]
  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

jira-firefox: &jira-firefox
  name: JIRA Firefox tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:firefox -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]

  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

jira-electron: &jira-electron
  name: JIRA Electron tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:electron -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]

  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

pipelines:
  default:
  - step:
      name: Install dependencies
      caches:
        - npm
        - cypress
        - node
      script:
        - npm ci
        - npx @bahmutov/print-env BITBUCKET
  - parallel:
    # cross-browser testing
    - step:
        <<: *jira-chrome    
    - step:
        <<: *jira-firefox
    - step:
        <<: *jira-electron
definitions:
  caches:
   npm: $HOME/.npm
   cypress: $HOME/.cache/Cypress

This will solve the issue. Thank you @jennifer-shehane you helped me a lot...!

kkislay commented 1 year ago

I am hitting the same issue when trying to run Cypress tests in Jenkins. The tests pass locally but in CI while running in parallel this issue is seen consistently. Cypress version - 11.1.0 Node version - 16.18.0 Browser - Chrome 94

`If you are trying to pass multiple arguments, separate them with commas instead:

cypress run --spec arg1,arg2,arg3

The most common cause of this warning is using an unescaped glob pattern. If you are

trying to pass a glob pattern, escape it using quotes:

cypress run --spec "*/.spec.js"

It looks like this is your first time using Cypress: 11.1.0

[STARTED] Task without title.

[SUCCESS] Task without title.

Opening Cypress...

Your system is missing the dependency: Xvfb

Install Xvfb and run Cypress again.

Read our documentation on dependencies for more information:

https://on.cypress.io/required-dependencies

If you are using Docker, we provide containers with all required dependencies installed.


Error: Display :101 is already in use and the "reuse" option is false.


Platform: linux-x64 (Red Hat Linux - 8.7)

Cypress Version: 11.1.0`

Attempt - I tried using xvfb-run -a command as well but got the same error.

RoopaShivakumar commented 1 year ago

Now, I solved this issue by using this configuration:

package.json:

"scripts": {

 "jira:chrome": "cypress run --group 1x-chrome --record --headless --browser chrome",

  "jira:firefox": "cypress run --group 1x-firefox --record --headless --browser firefox",

  "jira:electron": "cypress run --group 1x-electron --record  --headless --browser electron"
}

bitbucket-pipelines.yaml:


image: cypress/included:6.2.1
options:
  max-time: 10

# job definition cross-browser testing
jira-chrome: &jira-chrome
  name: JIRA Chrome tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:chrome -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]
  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

jira-firefox: &jira-firefox
  name: JIRA Firefox tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:firefox -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]

  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

jira-electron: &jira-electron
  name: JIRA Electron tests
  caches:
    - node
    - cypress
  script:
    - npx @bahmutov/print-env BITBUCKET
    - npm run jira:electron -- --ci-build-id $BITBUCKET_BUILD_NUMBER --key [Project_Key_From_Cypress_Dashboard]

  artifacts:
    # store any generates images and videos as artifacts
    - cypress/screenshots/**
    - cypress/videos/**

pipelines:
  default:
  - step:
      name: Install dependencies
      caches:
        - npm
        - cypress
        - node
      script:
        - npm ci
        - npx @bahmutov/print-env BITBUCKET
  - parallel:
    # cross-browser testing
    - step:
        <<: *jira-chrome    
    - step:
        <<: *jira-firefox
    - step:
        <<: *jira-electron
definitions:
  caches:
   npm: $HOME/.npm
   cypress: $HOME/.cache/Cypress

This will solve the issue. Thank you @jennifer-shehane you helped me a lot...!

Instead of docker image,.....I tried sending --headless option but even then it failed....ANy other wat to resolve this...It worked ifne when runnign from azure pipelines but running from a azure self hosted Linux vm its giving this issue

anilpujaraofficial commented 10 months ago

[STARTED] Task without title. [FAILED] Your system is missing the dependency: Xvfb [FAILED] [FAILED] Install Xvfb and run Cypress again. [FAILED] [FAILED] Read our documentation on dependencies for more information: [FAILED] [FAILED] https://on.cypress.io/required-dependencies [FAILED] [FAILED] If you are using Docker, we provide containers with all required dependencies installed. [FAILED] [FAILED] ---------- [FAILED] [FAILED] Error: spawn Xvfb ENOENT [FAILED] [FAILED] ---------- [FAILED] [FAILED] Platform: linux-x64 (Debian - 12.2) [FAILED] Cypress Version: 13.4.0 Your system is missing the dependency: Xvfb Install Xvfb and run Cypress again. Read our documentation on dependencies for more information: https://on.cypress.io/required-dependencies If you are using Docker, we provide containers with all required dependencies installed.

Error: spawn Xvfb ENOENT

Platform: linux-x64 (Debian - 12.2) Cypress Version: 13.4.0 ERROR: Job failed: exit code 1

how can solve this issue @jennifer-shehane