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

Having [fileName] or [scenarioName] as a mochaFile option, such as [hash] #144

Open
sandra-ouadghiri opened this issue Feb 19, 2021 · 4 comments

Comments

@sandra-ouadghiri
Copy link

sandra-ouadghiri commented Feb 19, 2021

Hi,

Request Type : Enhancement/Feature request (not a bug :) !)

Today
https://github.com/michaelleeallen/mocha-junit-reporter/blob/master/index.js#L486
By specifying "mochaFile": "<path>/[hash].xml" we have a unique file which name is a hash
Of course plain strings also work ("mochaFile": "<path>/test-output[hash].xml"). There's no other keyword I'm aware of.

Proposition
I'm using cucumber + cypress. I think this can apply to any situation though.
The produced .xml file contains tags, one having a file=<scenario-file> attribute (for ex file="cypress\integration\login\api.feature").

  • It would be really nice to have the option to do:
    "mochaFile": "<path>/[fileName].xml" -> report named api-034eb437b9bc00a7dc9b7b80924fdbfc.xml
  • And of course combinations if needed:
    "mochaFile": "<path>/[fileName]-[hash].xml" -> report named api.xml

That would be really useful.
Cypress make one report per file, so if I have 10 files containing each 20 tests, I get 10 files. The end goal for me would be to have file names (which are displayed in my reports) a bit clearer for an end user.

Here's an xml example this package generates

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="15.1970" tests="2" failures="0">
  <testsuite name="Root Suite" timestamp="2021-02-19T13:43:54" tests="0" file="cypress\integration\login\api.feature" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="API Authentication" timestamp="2021-02-19T13:43:54" tests="2" time="15.1970" failures="0">
    <testcase name="API Authentication API Login" time="10.1700" classname="API Login">
    </testcase>
    <testcase name="API Authentication API Logout" time="5.0270" classname="API Logout">
    </testcase>
  </testsuite>
</testsuites>
@timstapl
Copy link

timstapl commented Feb 2, 2022

Looking at the source it does look like [hash] is the only supported keyword.

Would you accept a PR to add [fileName] and perhaps one or two others?

@mlegait
Copy link

mlegait commented Apr 5, 2022

This is a really helpful feature, do you know why the open PR is not merged yet?

@HeshamMoneer
Copy link

HeshamMoneer commented Apr 26, 2022

@michaelleeallen
Can you please merge this PR?

@gian1200
Copy link

That PR allows the renaming of the only report file, correct? It doesn't create multiple files (one per testsuite), when using [suiteName], right? Is there a way to split the report into multiple report files?

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

5 participants