Closed msesun closed 2 years ago
Same issue here, upgraded from Cypress 9.7 to 10.3.0 and getting the same stacktrace:
Start generate report process
Read and merge jsons from "cypress\report\.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 cypress\report\.jsons/*.json matched no report files
at mycode\node_modules\mochawesome-merge\lib\index.js:14:11
Used the configuration as shown in the Readme.
The issue seems to be that the cwd is the cypress config directory, so when its looking for the json files relative from this directory it wont work.
A workaround that works for me is to edit the reportDir
that is passed to the beforeRunHook
, to make it relative to the config directory. The afterRunHook
can stay the same:
setupNodeEvents(on, config) {
on('before:run', async (details) => {
let newDetails = {...details};
newDetails.config.reporterOptions.reportDir= '../report';
await beforeRunHook(newDetails);
});
on('after:run', async () => {
await afterRunHook();
});
},
@richardhendricksen can you please describe your folder structure?
something like:
package.json
cypress.config.js
cypress/
e2e/
test.cy.js
reports/
html/
index.html
It would help me understand the issue
@msesun is the solution @richardhendricksen wrote solves your issue?
@LironEr My folder structure is almost as you described, only I have multiple config files for specific OTAP environments and I put those in a separate subdirectory:
cypress/
config/
local.config.ts
dev.config.ts
test.config.ts
e2e/
*.cy.ts files
report/
html/
index.html
Hi, I have the same issue :/ any luck with downgrading cypress or mochawesome-reporter or something?
So this workaround should point to the same "reports" dir where reporter is creating reports?
let newDetails = {...details};
newDetails.config.reporterOptions.reportDir= '../report';
I got it resolved and that not an issue with Cypress or mochawesome-reporter versions, I had an mistake in configuration.
@LironEr Yes, adding the before hook @richardhendricksen shared to change the reports directory solves the issue. Thank you both!
This is still a workaround, and I'm curious what changed, but sounds like maybe it's a Cypress issue not a cypress-mochawesome-reporter issue.
I think the issue is due to Cypress 10 having the plugins executed from the config file directly while in previous versions we were just defining the path to the plugins file in the config.
I had the same issue and got it fixed by this. Thanks @richardhendricksen
Same issue here, upgraded from Cypress 9.7 to 10.3.0 and getting the same stacktrace:
Start generate report process Read and merge jsons from "cypress\report\.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 cypress\report\.jsons/*.json matched no report files at mycode\node_modules\mochawesome-merge\lib\index.js:14:11
Used the configuration as shown in the Readme.
The issue seems to be that the cwd is the cypress config directory, so when its looking for the json files relative from this directory it wont work. A workaround that works for me is to edit the
reportDir
that is passed to thebeforeRunHook
, to make it relative to the config directory. TheafterRunHook
can stay the same:setupNodeEvents(on, config) { on('before:run', async (details) => { let newDetails = {...details}; newDetails.config.reporterOptions.reportDir= '../report'; await beforeRunHook(newDetails); }); on('after:run', async () => { await afterRunHook(); }); },
It might be related to a fix I released https://github.com/LironEr/cypress-mochawesome-reporter/issues/95#issuecomment-1207170180
I will release an official version in a few days.
@LironEr Thanks!
Environment
What happened?
We have been using Cypress version 9.7.0 with the cypress-mochawesome-reporter and everything is working great.
When upgrading Cypress to 10.2.0, the reporter is now unable to find our reports folder to run the merge feature and create the index.html report.
The Cypress tests run successfully, the screenshots and mochawesome*.json files all generate correctly and are put in the right place. It's just when the final step of generating the html report where there is a failure.
Are there configuration updates needed for the cypress-mochawesome-reporter with the new version of Cypress?
Config file
Relevant log output
Anything else?
No response