LironEr / cypress-mochawesome-reporter

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

reportDir option works only with default value #41

Closed tr4ck3ur closed 3 years ago

tr4ck3ur commented 3 years ago

Describe the bug by giving as 'reportDir' option another value than the default one, (aka cypress/reports). report auto-generation fails As an example, I put "reportDir": "./results/html" And the, at the end of the execution :

Read and merge jsons from "results\html\.jsons"
An error was thrown in your plugins file while executing the handler for the 'after:run' event.

The error we received was:

Error: Pattern results\html\.jsons/*.json matched no report files

*and yes i confirm, mochawesome.json files are generated inside cypress/reports/html/.jsons folder**

Expected behavior I think it may generate mochawesome*.json in a folder according to reportDir option, not using a 'default value'

Environment

.... +-- @nrwl/cypress@12.4.0 +-- @nrwl/workspace@12.4.0 +-- cypress-mochawesome-reporter@2.2.0 +-- cypress-multi-reporters@1.5.0 +-- cypress@7.5.0 +-- mocha-junit-reporter@2.0.0 +-- mocha@9.0.1 +-- mochawesome-merge@4.2.0 +-- mochawesome@6.2.2 ....

System:

cypress.json:

{
 ... other config here ...

  "reporter": "../node_modules/cypress-multi-reporters",
  "reporterOptions": {
    "reporterEnabled": "../node_modules/cypress-mochawesome-reporter, ../node_modules/mocha-junit-reporter",
    "mochaJunitReporterReporterOptions": {
      "mochaFile": "./results/junit/results-[hash].xml",
      "testsuitesTitle": "Reporting-UI"
    },
    "cypressMochawesomeReporterReporterOptions": {
      "charts": true,
      "reportPageTitle": "Reporting-UI",
      "embeddedScreenshots": true,
      "reportDir": "./results/html"
    }
  }
}
LironEr commented 3 years ago

I tried to reproduce the bug and I saw this logs:

"../node_modules/cypress-mochawesome-reporter" reporter not found
Reporter not found! ../node_modules/cypress-mochawesome-reporter
"../node_modules/mocha-junit-reporter" reporter not found
Reporter not found! ../node_modules/mocha-junit-reporter

When I changed reporterEnabled from:

"reporterEnabled": "../node_modules/cypress-mochawesome-reporter, ../node_modules/mocha-junit-reporter",

to:

"reporterEnabled": "cypress-mochawesome-reporter, mocha-junit-reporter",

everything worked as expected.

Do you see that log also? If not, please provide a repo so I can test it or provide steps to reproduce the bug.

tr4ck3ur commented 3 years ago

In fact, i do it because i fall in following issue: https://github.com/cypress-io/cypress/issues/4536 I forgot to say that i have a nested folder 'e2e' where i put cypress tests, that's why i put "../node_modules/" as a prefix with your proposal i get following error

Could not load reporter by name: cypress-multi-reporters

We searched for the reporter in these paths:

  • \e2e\cypress-multi-reporters
  • \e2e\node_modules\cypress-multi-reporters

Ok, my bad i updated by mistake the wrong line

"reporter": "../node_modules/cypress-multi-reporters",

Re-testing

tr4ck3ur commented 3 years ago

I confirm that works @LironEr "reporter":

"../node_modules/cypress-multi-reporters",

being kept, then reporterEnabled changed to :

"reporterEnabled": "cypress-mochawesome-reporter, mocha-junit-reporter",

as suggested works fine

Thanks !