Name of the report is not saving as expected (even though 'reportFilename' in cypress.json file is changed)
See original GitHub issuei 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 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
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 help me to resolve this @adamgruber ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Name of the mochawesome report is not saving as expected ...
Name of the mochawesome report is not saving as expected (even though 'reportFilename' in cypress.json is changed).
Read more >mochawesome/general - Gitter
Hello guys, recently we noticed some tests appeared as skipped in the JSON report and we don't understand why. The day before, no...
Read more >Cypress — generating mochawesome reports | by Kristijan
You can generate these reports by using reporter flag when running tests. Example: cypress run --reporter mochawesome. Usually you do not want to...
Read more >Reporters | Cypress Documentation
We want to output a "spec" report to STDOUT , save an individual Mochawesome JSON file per test file, and then combine all...
Read more >Configuration - Cypress Documentation
This guide is for Cypress 10 and the new JavaScript configuration file format. If you are on an older version of Cypress that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking into this a bit, adding the feature is pretty straightforward but to work with Cypress will require https://github.com/cypress-io/cypress/issues/1495 to be complete.
This will not work because the reporter has already been created with the initial options and no longer references the Cypress config. There is currently no way to have custom filenames for each test.