【问题标题】:Why cypress module is not detecting while running sorry-cypress run command?为什么在运行 sorry-cypress run 命令时没有检测到 cypress 模块?
【发布时间】:2021-09-27 07:16:20
【问题描述】:

当我尝试运行 sorry-cypress command 用于并行运行测试用例时

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

即使安装了 cypress,它也会抛出错误。 这是sorry-cypress设置链接

sorry-cypress npm 模块基本链接: 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)

这是我的 package.json 文件

{
  "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"
  }
}

【问题讨论】:

    标签: npm cypress


    【解决方案1】:

    这里的问题是 cy2 模块的位置。

    运行此命令将有助于解决此问题。

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

    我在这里更改的是cy2./node_modules/cy2/bin/cy2

    因为 cy2 不能直接访问。

    安装 cy2 模块 通过 npm 将在 node_module 中安装 cy2。

    Yarn add 可用于直接访问 cy2 模块。

    【讨论】:

    • 谢谢,伙计!令人兴奋的是它包含在官方文档中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 2020-07-07
    相关资源
    最近更新 更多