stanleyhlng / mocha-multi-reporters

Generate multiple mocha reports in a single mocha execution.
MIT License
74 stars 22 forks source link

xunit.xml appears even when not using XUnit reporter #35

Closed davidwesst closed 6 years ago

davidwesst commented 7 years ago

Expected behavior

No xunit.xml file should appear in root directory.

Actual behavior

File named xunit.xml appears when tests are run.

Information about the Issue

Looking at the code, I found that line 68 references is local project config.json file, which is configured for XUnit.

Changing this file to point at my the executable directory config.json file would only use the project's config.json file.

Steps to reproduce the behavior

  1. Setup a project with a config.json, where XUnit is not being used.
  2. Run tests with mocha-multi-reporters
davidwesst commented 7 years ago

I'm hoping to submit a pull request ASAP, as I've tested this locally and it appears to work fine. Just need to make sure I'm not breaking something else.

stanleyhlng commented 7 years ago

Hi @davidwesst,

The xunit test report will be used by default. To disable xunit test reporter, you can localize the setting by creating the following config.json file.

$  cat config.json
{
    "reporterEnabled": "tap"
}

I have created a demo branch for your to verify. https://github.com/stanleyhlng/mocha-multi-reporters-demo/blob/issue35-xunit.xml/config.json

Hope this help,

Thanks, Stanley

blabno commented 7 years ago

I believe you forgot about configFile

mocha -R mocha-multi-reporters --reporter-options configFile=config.json

stanleyhlng commented 6 years ago

@davidwesst please re-open this issue if you still have the same problem.

jpshack-at-palomar commented 5 months ago

I stumbled over this too and found the source by running DEBUG=mocha:reporters:MultiReporters npm test -- the problem was misconfigured .mocharc.json. I got it working with the following:

.mocharc.json :

  "reporter": "mocha-multi-reporters",
  "reporterOptions": {
    "configFile": ".mocha-multi-reporters.json"
  },

.mocha-multi-reporters.json :

{
    "reporterEnabled": "spec"
}

My error had been using reporter-options instead of reporterOptions and assuming that I could put all configuration in .mocharc.json rather than setting up the required configFile.