Home > Enterprise >  Cypress Github Actions showing peer dependency conflict errors
Cypress Github Actions showing peer dependency conflict errors

Time:08-26

I'm trying to set up a workflow to run automated cypress tests in GitHub Actions but continue to run into this error message

npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/cypress
npm ERR!   dev cypress@"^8.4.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer cypress@"^4.5.0" from [email protected]
npm ERR! node_modules/cypress-plugin-snapshots
npm ERR!   dev cypress-plugin-snapshots@"1.4.4" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/cypress
npm ERR!   peer cypress@"^4.5.0" from [email protected]
npm ERR!   node_modules/cypress-plugin-snapshots
npm ERR!     dev cypress-plugin-snapshots@"1.4.4" from the root project

I don't have permission to embed images, but here's a screenshot of the entire error message

Relevant section of the YAML workflow:

jobs:
  cypress-run:
    runs-on: ubuntu-latest
      
    steps:
      - name: Checkout
        uses: actions/checkout@v3 
      
      - name: Cypress Run
        uses: cypress-io/github-action@v4
        with:
          build: npm run build
          start: npm start 
          spec: cypress/integration/example.js

package.json:

{
  "name": "cypressautomations",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "cypress:open": "cypress open",
    "cypress:debug": "cross-env CYPRESS_REMOTE_DEBUGGING_PORT=9222 cypress open",
    "delete-mochawesome-folder": "rm -f mochawesome-report/*.json",
    "e2e_mochawesome": "yarn cypress run --spec cypress/integration/Tests/*.js",
    "merge-json": "npx mochawesome-merge --reportDir mochawesome-report > mochawesome1.json",
    "html-generator": " npx mochawesome-report-generator mochawesome1.json"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@cypress/snapshot": "2.1.7",
    "cross-env": "7.0.3",
    "cypress": "^8.4.1",
    "cypress-fail-on-console-error": "2.0.6",
    "cypress-multi-reporters": "1.4.0",
    "cypress-plugin-snapshots": "1.4.4",
    "cypress-wait-until": "1.7.1",
    "eslint": "7.26.0"
  },
  "dependencies": {
    "@azure/cosmos": "3.10.5",
    "bson-ext": "4.0.1",
    "dotenv": "8.2.0",
    "kerberos": "1.1.7",
    "lodash": "4.17.21",
    "mocha-junit-reporter": "2.0.0",
    "mochawesome": "6.2.2",
    "mochawesome-merge": "4.2.0",
    "mochawesome-report-generator": "5.2.0",
    "mongodb": "4.1.2",
    "mongodb-client-encryption": "1.2.7"
  },
  "peerDependencies": {
    "mocha": "3.1.2"
  }
}

I tried doing a run with the --legacy-peer-deps flag by adding the following code after the "Checkout" step

- name: Install Dependencies
  run: npm ci --legacy-peer-deps

but the error persists. It looks like the 'Cypress Run' action runs the 'npm ci' command as part of its own workflow, even if dependencies are already installed.

Any insight into this problem would be greatly appreciated.

CodePudding user response:

I was running into the same issue and figured the same thing with the Cypress Run command. It's doing the npm installation for you.

I fixed this by separating the installation from the action and build, as well as setting the action installation as false:

 steps:
  - name: Checkout
    uses: actions/checkout@v2
  # Install NPM dependencies, cache them correctly
  # and run all Cypress tests
  - name: Cypress install
    run: npm install --legacy-peer-deps
  - name: Cypress run
    uses: cypress-io/github-action@v2
    with:
      install: false
      build: npm run build
      start: npm start
      run: npm run dev

Cypress is now running my E2E tests.

  • Related