Search code examples
npmcypressconcourseconcourse-fly

Error on Concurse while integrating Cypress. Cypress executable not found


I'm trying to integrate cypress with concourse. I was referring to these steps. mentioned here, https://notes.dmitriydubson.com/testing/e2e-testing/cypress-and-concourse/ . However, I'm getting this error. Any help is much appreciated.

    > [email protected] testHeadless /tmp/build/ae3c03f4/cypressgit
> cypress run

No version of Cypress is installed in: /root/.cache/Cypress/7.3.0/Cypress

Please reinstall Cypress by running: cypress install

----------

Cypress executable not found at: /root/.cache/Cypress/7.3.0/Cypress/Cypress

----------

Platform: linux (Debian - 8.11)
Cypress Version: 7.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] testHeadless: `cypress run`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] testHeadless 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/2022-01-03T05_27_23_867Z-debug.log

This is my yaml file.

pipeline.yml

resources:
- name: cypressgit
  type: git
  icon: github
  source:
    uri: https://github.com/Sparsh79/LearningCypress.git
    branch: master

jobs: 
- name: test
  serial: true
  plan:
  - get: cypressgit
    trigger: true
  - task: runtests
    privileged: true
    file: cypressgit/test.yml

test.yml

    platform: linux

image_resource:
  type: docker-image
  source:
    repository: ddubson/cypress-e2e

inputs:
  - name: cypressgit
outputs:
  - name: npm-output

run:
  path: /bin/bash
  args:
    - cypressgit/ci/e2e.sh

e2e.sh

    cd cypressgit/

npm run testHeadless

test command in package.json

"scripts": {
    "testHeadless": "node_modules/.bin/cypress run",
    "withHeadTest": "npm run testHeadless -- --headed",
    "chromeTest": "npm run testHeadless -- --browser chrome"
}

Solution

  • Quick fix: if you want to push the job to completion, amend the e2e.sh file to install cypress in the container along with its dependency:

    # new e2e.sh
    cd cypressgit/
    apt install -y libgbm1
    npx cypress install
    npm run testHeadless
    

    It will work, however, it will reinstall cypress every time you run the container. So...

    Proper fix:

    1. Create a docker container from ddubson/cypress-e2e; install cypress and libgbm1 on it and publish it to docker.
    2. Update the repository in test.yml to your freshly published container handle in dockerhub.
    3. Re-run the test and profit!