i am using mochawesome for my cypress tests.
This is my cypress.json file
{
"viewportWidth": 1440,
"viewportHeight": 800,
"defaultCommandTimeout": 8000,
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/reports/mochawesome-report",
"reportFilename": "sample",
"overwrite": false,
"html": true,
"json": true
},
"env": {
"environment": "Stagging"
},
"screenshotsFolder": "cypress/reports/mochawesome-report/assets",
}
when I ran my tests, the reports are generated with name 'sample.html' which is expected as I have defined my report title as sample in cypress.json file.
now I wanted to have a unique name for each report generated based on the test suite name.
so I have used the cypress event 'test:before:run
' and set the reportFilename
in cypress.json to the test suite name before the execution of each test, the sample code is down below
Cypress.on("test:before:run", (test, runnable) => {
console.log(Cypress.config("reporterOptions").reportFilename);
const suiteTitle = runnable.parent.title;
Cypress.config({
"reporterOptions":{
"reportFilename": suiteTitle
}
});
const reportFileName = Cypress.config("reporterOptions").reportFilename;
console.log(reportFileName);
});
I see the reportFilename
is successfully changed to Tests suite name in configuration file
But my report is still saved as 'sample.html'
Why my report is still saving as sample.html , instead of my test suite name?
can you someone help me to resolve this?
This is not an issue, this requires new enhancement to moachawesome codebase and looking for help