我正在尝试设置一个工作流程,以在GitHub Actions中运行自动化的柏树测试,但仍会遇到此错误消息
npm ERR! While resolving: cypress-plugin-snapshots@1.4.4
npm ERR! Found: cypress@8.4.1
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 cypress-plugin-snapshots@1.4.4
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: cypress@4.12.1
npm ERR! node_modules/cypress
npm ERR! peer cypress@"^4.5.0" from cypress-plugin-snapshots@1.4.4
npm ERR! node_modules/cypress-plugin-snapshots
npm ERR! dev cypress-plugin-snapshots@"1.4.4" from the root project
我没有嵌入图像的权限,但这是整个错误消息的屏幕截图
YAML工作流程的相关部分:
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"
}
}
我试着用--legacy peer deps标志运行,在";结账";步进
- name: Install Dependencies
run: npm ci --legacy-peer-deps
但是错误仍然存在。看起来"Cypress Run"操作将"npm-ci"命令作为其自身工作流程的一部分运行,即使已经安装了依赖项。
如能深入了解这个问题,我们将不胜感激。
我遇到了同样的问题,并用Cypress Run命令处理了同样的事情。它正在为您安装npm。
我通过将安装与操作和构建分离,并将操作安装设置为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现在正在运行我的E2E测试。