LironEr / cypress-mochawesome-reporter

Zero config Mochawesome reporter for Cypress with screenshots and videos
MIT License
159 stars 49 forks source link

Error with the reporter in the after:run event when running it in the Github CI #101

Closed marijana-rukavina closed 2 years ago

marijana-rukavina commented 2 years ago

Environment

- OS: linux/amd64 - running inside docker (This image is used https://hub.docker.com/layers/included/cypress/included/9.5.2/images/sha256-a8f0770a0be0d6486a75b4f8ba151e412adb7f443e192171cc25c36a6ef49afd?context=explore)
- Node: 16.14.0
- cypress-mochawesome-reporter: 3.1.0
- cypress: 9.5.2

What happened?

When I am running my test suite locally, then everything works. But when I try to run it in the Github Actions, I get this error, and my .html report file is not generated:

override after:run
Start generate report process
Read and merge jsons from "/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/cypress/reports/html/.jsons"
Screenshots folder "/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/cypress/screenshots" not found, nothing to copy
An error was thrown in your plugins file while executing the handler for the after:run event.

The error we received was:

Error: Pattern /__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/cypress/reports/html/.jsons/*.json matched no report files
    at /__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/mochawesome-merge/lib/index.js:14:11
    at Array.map (<anonymous>)
    at /__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/mochawesome-merge/lib/utils.js:3:46
    at merge (/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/mochawesome-merge/lib/index.js:[82](https://github.com/interdiscount/commercecloud-ui-test-automation/runs/8071293069?check_suite_focus=true#step:7:83):17)
    at mergeAndCreate (/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/cypress-mochawesome-reporter/lib/generateReport.js:12:24)
    at generateReport (/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/cypress-mochawesome-reporter/lib/generateReport.js:56:20)
    at afterRunHook (/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/node_modules/cypress-mochawesome-reporter/lib/index.js:35:9)
    at Object.handler (/__w/commercecloud-ui-test-automation/commercecloud-ui-test-automation/cypress/plugins/index.js:58:11)
    at invoke (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:22:16)
    at /root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/util.js:45:14
    at tryCatcher (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Object.wrapChildPromise (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/util.js:44:23)
    at wrapChildPromise (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:116:10)
    at execute (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:129:14)
    at EventEmitter.<anonymous> (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:213:5)
    at EventEmitter.emit (node:events:520:28)
    at process.<anonymous> (/root/.cache/Cypress/9.5.2/Cypress/resources/app/packages/server/lib/plugins/util.js:19:22)
    at process.emit (node:events:520:28)
    at process.emit (/root/.cache/Cypress/9.5.2/Cypress/resources/app/node_modules/source-map-support/source-map-support.js:495:21)
    at emit (node:internal/child_process:938:14)
    at processTicksAndRejections (node:internal/process/task_queues:[84](https://github.com/interdiscount/commercecloud-ui-test-automation/runs/8071293069?check_suite_focus=true#step:7:85):21)
Error: Process completed with exit code 1.

Config file

This is my package.json file
 "devDependencies": {
    "@cypress/skip-test": "^2.6.1",
    "@testing-library/cypress": "^8.0.2",
    "@types/jquery": "^3.5.6",
    "@types/node": "^16.4.11",
    "cy2": "^2.0.0",
    "cypress": "^9.5.2",
    "cypress-grep": "^2.10.3",
    "cypress-mochawesome-reporter": "^3.1.0",
    "cypress-multi-reporters": "^1.6.1",
    "cypress-xpath": "^1.6.2",
    "eslint-plugin-cypress": "^2.11.1",
    "gmail-tester": "^1.3.2",
    "mocha-junit-reporter": "^2.0.0",
    "prettier": "2.0.2",
    "tslint-plugin-cypress": "^1.0.4",
    "typescript": "^4.3.5"
  },
  "lint-staged": {
    "cypress/**/*.{js}": [
      "eslint . --fix",
      "git add"
    ]
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "lint-staged"
    }
  },
  "prettier": {
    "printWidth": 150,
    "singleQuote": true
  },
  "dependencies": {
    "date-fns": "^2.24.0",
    "generate-password": "^1.6.0",
    "tslint": "^6.1.3"
  }

My Cypress.json file

{
  "watchForFileChanges": false,
  "defaultCommandTimeout": 60000,
  "requestTimeout": 20000,
  "viewportWidth": 1920,
  "viewportHeight": 1080,
  "chromeWebSecurity": false,
  "videoUploadOnPasses": false,
  "numTestsKeptInMemory": 0,
  "retries": 2,
  "projectId": "My project",
  "reporter": "cypress-mochawesome-reporter",
  "reporterOptions": {
    "inline": true,
    "reportDir": "cypress/reports",
    "charts": true,
    "reportPageTitle": "My project report",
    "embeddedScreenshots": true,
    "saveAllAttempts": true,
    "reportFilename": "[status]_[datetime]-[name]-report"
  },
  "projectId": "My project",
  "env": {
    "dataEnv": "",
    "completeFullCheckout": true,
    "emailChecksEnabled": false,
    "maxWaitTimeForEmailsSeconds": 600
  }
}

reporter-config.json file

{
    "reporterEnabled": "spec, mocha-junit-reporter",
    "mochaJunitReporterReporterOptions": {
      "mochaFile": "cypress/results/results-[hash].xml"
    }
  }

Relevant log output

Already pasted above

Anything else?

This is the command in yaml file which is used to run the tests:
Run npm ci && cypress run --spec 'cypress/integration/project/checkout/addToCart-spec.ts' --env configFile=stage --config pageLoadTimeout=60000,retries=3,video=false,screenshotOnRunFailure=true --reporter cypress-multi-reporters --reporter-options configFile=reporter-config.json

marijana-rukavina commented 2 years ago

@LironEr any insights on this one? :D

marijana-rukavina commented 2 years ago

The issue was I was having this --reporter cypress-multi-reporters --reporter-options configFile=reporter-config.json extra in the yaml file. When I removed it, it worked fine. Sorry, my bad, not a bug