当所有 spec.js 文件都通过时,会生成 raport 并且一切正常。当只有一个或多个测试失败时,就会发生一些奇怪的事情。有许多警告和错误,但仍会生成报告。报告似乎也生成了两次(仅在失败时)。为什么?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress-tests@1.0.0 scripts-chrome: `cypress run --browser chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cypress-tests@1.0.0 scripts-chrome script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dawid\AppData\Roaming\npm-cache\_logs\2021-11-02T07_12_01_140Z-debug.log
> cypress-tests@1.0.0 posttest-chrome E:\Cypress
> npm run combine-reports-chrome && npm run generate-report-chrome
> cypress-tests@1.0.0 combine-reports-chrome E:\Cypress
> mochawesome-merge cypress/reports/current/mocha/*.json > cypress/reports/current/chrome/mochareports/report.json
> cypress-tests@1.0.0 generate-report-chrome E:\Cypress
> marge cypress/reports/current/chrome/mochareports/report.json -f report -o cypress/reports/current/chrome/mochareports
✓ Reports saved:
E:\Cypress\cypress\reports\current\chrome\mochareports\report.html
> cypress-tests@1.0.0 posttest-chrome E:\Cypress
> npm run combine-reports-chrome && npm run generate-report-chrome
> cypress-tests@1.0.0 combine-reports-chrome E:\Cypress
> mochawesome-merge cypress/reports/current/mocha/*.json > cypress/reports/current/chrome/mochareports/report.json
> cypress-tests@1.0.0 generate-report-chrome E:\Cypress
> marge cypress/reports/current/chrome/mochareports/report.json -f report -o cypress/reports/current/chrome/mochareports
✓ Reports saved:
E:\Cypress\cypress\reports\current\chrome\mochareports\report.html
PS E:\Cypress>
这是我生成报告的代码
"scripts": {
"clean:reports-chrome": "rmdir /S /Q cypress\\reports\\current && mkdir cypress\\reports\\current\\chrome\\mochareports",
"pretest-chrome": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./pretest.ps1 && npm run clean:reports-chrome",
"scripts-chrome": "cypress run --browser chrome",
"combine-reports-chrome": "mochawesome-merge cypress/reports/current/mocha/*.json > cypress/reports/current/chrome/mochareports/report.json",
"generate-report-chrome": "marge cypress/reports/current/chrome/mochareports/report.json -f report -o cypress/reports/current/chrome/mochareports",
"posttest-chrome": "npm run combine-reports-chrome && npm run generate-report-chrome",
"test-chrome": "npm run scripts-chrome || npm run posttest-chrome",