michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.
MIT License
144 stars 153 forks source link

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

Open sandra-ouadghiri opened 3 years ago

sandra-ouadghiri commented 3 years ago

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").

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 commented 2 years ago

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 commented 2 years ago

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

HeshamMoneer commented 2 years ago

@michaelleeallen Can you please merge this PR?

gian1200 commented 4 months ago

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?