I am trying to implement dynamic path to mochawesome reports for different browsers e.g for example, for chrome it is supposed to be cypress/reports/chrome/mocha
This is my cypress.json configuration for reporter
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"reporterEnabled": "mochawesome",
"mochawesomeReporterOptions": {
"quiet": true,
"overwrite": false,
"html": false,
"json": true
}
},
And this is how I'm trying to run tests with custom reporterDir
"cypress run --spec cypress\\integration\\filter\\*.js --browser chrome --headless --config-file config.json --config videosFolder=cypress\\videos\\chrome downloadsFolder=cypress\\downloads\\chrome --reporter mochawesome --reporter-options reportDir=cypress/reports/chrome/mocha"
but it doesnt work. Reports are saved under path from cypress.json. I tried different syntax many times but I just can't make it work. I need it because my tests will be launched on many browsers and I want to make reports directory well organised.
I ended up with https://www.npmjs.com/package/@bahmutov/cypress-extends - plugin responsible for extending cypress configuration file so I have created one for each browser with its own path for reports, videos and downloads and now I'm launching scripts like that "cypress run --spec cypress\\integration\\*.js --browser chrome --config-file config_BROWSER.json"
. I have also deleted multi-reporters plugins because I realized I don't need it.
Cypress.json
"reporter": "mochawesome",
"reporterOptions": {
"quiet": true,
"overwrite": false,
"html": false,
"json": true,
}
config_chrome.json
{
"extends": "./cypress.json",
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/reports/chrome/mocha"
},
"videosFolder": "cypress/videos/chrome",
"downloadsFolder": "cypress/downloads/chrome"}
and then config_edge.json and config_firefox.json - similar to chrome but with different paths