Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get the title of my spec file/describe as my HTML report file namne #185

Closed
Saif4 opened this issue Feb 4, 2022 · 5 comments
Closed

Comments

@Saif4
Copy link

Saif4 commented Feb 4, 2022

Let's say I have 3 spec files that each one of them has its own describe. When I run all 3 files together mochawesome report will be generated as
mochawesome.html
mochawesome_001.html
mochawesome_002.html

Is it a way to inherit the spec file name or even the descripe name of the spec file into the reports?

@adamgruber
Copy link
Owner

When I run all 3 files together

Can you provide more details on how you are running your tests? What options are you passing to the reporter? Based on your comment I would expect a single report to be output, not 3.

@Saif4
Copy link
Author

Saif4 commented Feb 7, 2022

"reporter": "mochawesome",
"reporterOptions": {
"charts": true,
"overwrite": false,
"html": true,
"json": true,
"reportDir": "cypress/reports/",
},

It become 3 reports because I have 3 spec files with each describe command inside them, and that's why I'm getting 3 reports after each describe has finished. So the html reports become as the follow:
mochawesome.html
mochawesome_001.html
mochawesome_002.html

But what I want is to inherit the name of my describe or the spec file it self.

In my case I have 3 spec files with each describe command inside with those those names
accounts.spec.js --> describe name (Accounts)
members.spec.js --> describe name (Members)
admins.spec.js --> describe name (Admins)

For my case I want the mochawesome reports to be:
accounts.html
members.html
admins.html

instead of the default name.

@Saif4
Copy link
Author

Saif4 commented Feb 21, 2022

@adamgruber

@adamgruber
Copy link
Owner

The functionality you are looking for is not currently available. There are some differences with how standalone mocha works and how it works when using cypress. These differences make adding this feature non-trivial but I am trying to find a solution that will work for the majority of cases.

@adamgruber
Copy link
Owner

With v7.1.0 this is now possible. See https://github.com/adamgruber/mochawesome#reportfilename-replacement-tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants