question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Name of the report is not saving as expected (even though 'reportFilename' in cypress.json file is changed)

See original GitHub issue

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 unique name for each report generated based on the test suite name.

so I have used the cypress eventtest: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

image

But my report is still saved as ‘sample.html’ image

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:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adamgrubercommented, Nov 1, 2019

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.

1reaction
adamgrubercommented, Oct 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found