Home > Enterprise >  Why cypress module is not detecting while running sorry-cypress run command?
Why cypress module is not detecting while running sorry-cypress run command?

Time:09-30

When I try to run sorry-cypress command which is for running test cases parallel

CYPRESS_API_URL="http://localhost:1234/" cy2 run --parallel --record --key somekey --ci-build-id hello-cypress

It throws error even though cypress is installed. Here is the sorry-cypress setup link

sorry-cypress npm module basic link : https://docs.sorry-cypress.dev/guide/get-started

Error: Cannot detect cypress. Is cypress installed?
   at getStateModulePath (/home/ashish/.nvm/versions/node/v14.17.5/lib/node_modules/cy2/lib/patch.js:90:11)

Here is my package.json file

{
  "name": "test-automation",
  "version": "1.0.0",
  "main": "index.js",
  "devDependencies": {
    "cucumber-html-reporter": "5.5.0",
    "cypress": "^8.4.1",
    "cypress-cucumber-preprocessor": "4.1.4",
    "cypress-plugin-tab": "1.0.5",
    "cypress-wait-until": "1.7.1",
    "eslint": "7.30.0",
    "eslint-plugin-cypress": "2.11.3",
    "junit-report-merger": "2.2.3"
  },
  "engines": {
    "node": "14"
  },
  "scripts": {
    "open": "cypress open",
    "api": "cypress run --headless --browser chrome --spec \"cypress/integration/API/**/*\"",
    "ui": "cypress run --browser chrome --spec \"cypress/integration/UI/**/*\"",
    "delete:reports": "rm cypress/results/* || true",
    "combine:reports": "jrm cypress/results/combined-report.xml \"cypress/results/*.xml\"",
    "prechrome": "yarn run delete:reports",
    "chrome": "cypress run --browser chrome",
    "postchrome": "yarn run combine:reports",
    "docker:pull": "docker pull cypress/included:7.6.0",
    "predocker:e2e": "yarn run delete:reports",
    "docker:e2e": "docker run -it -v $PWD:/e2e -w /e2e --entrypoint=cypress cypress/included:7.6.0 run --headless --browser chrome",
    "postdocker:e2e": "yarn run combine:reports",
    "generate:report": "node cypress/cucumber-html-reporter.js"
  },
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  },
  "dependencies": {
    "cy2": "^1.3.0"
  }
}

CodePudding user response:

Here issue was the location of cy2 module.

Running this command will help to solve this issue.

CYPRESS_API_URL="http://localhost:1234/" ./node_modules/cy2/bin/cy2 run --parallel --record --key somekey --ci-build-id hello-cypress

What I changed here is cy2 with ./node_modules/cy2/bin/cy2

Because cy2 directly not accessible.

Installing cy2 module through npm will install cy2 in node_module.

Yarn add will work for directly accessing cy2 module.

  • Related