michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sandra-ouadghiri opened this issue · comments

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>

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?

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

@michaelleeallen
Can you please merge this PR?