#npm #cypress
Вопрос:
Когда я пытаюсь запустить sorry-cypress command
, который предназначен для параллельного запуска тестовых случаев
CYPRESS_API_URL="http://localhost:1234/" cy2 run --parallel --record --key somekey --ci-build-id hello-cypress
Он выдает ошибку, даже если cypress установлен.
Вот ссылка для настройки sorry-cypress
извините-базовая ссылка на модуль npm cypress : 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"
}
}
Ответ №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 приведет к установке cy2 в node_module.
Добавление пряжи будет работать для прямого доступа к модулю cy2.
Комментарии:
1. Спасибо, чувак! умопомрачительно, что это включено в официальные документы.