Skip to content

Bug: command line reporter-options parameter doesn't override .mocharc.yml #5532

@stalb

Description

@stalb

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have 'smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

Mocha should use the reporter-options specified on the command-line instead of the one defined in .mocharc.yml.

Actual

Mocha use the reporter-options defined in .mocharc.yml instead of the one specified on the command-line.

Minimal, Reproducible Example

  1. Define a .mocharc.yml file with reporter-options:
recursive: true
reporter: xunit
reporter-options:
  - 'output=./test-reports/xunit.xml'
  1. Call mocha using a different value for reporter-options:
node node_modules/mocha/bin/mocha --reporter-options output=./test-reports/xxxunit.xml
  1. Verify that mocha has created ./test-reports/xunit.xml and not ./test-reports/xxxunit.xml

Versions

Debian Bookworm / Mocha version 6.2.3 / Node version v24.11.0 -> work as expected
Debian Bookworm / Mocha version 7.2.0 / Node version v24.11.0 -> work as expected
Debian Bookworm / Mocha version 7.2.0 / Node version v24.11.0 -> work as expected
Debian Bookworm / Mocha version 8.2.1 / Node version v24.11.0 -> work as expected
Debian Bookworm / Mocha version 8.3.0 / Node version v24.11.0 -> do not work as expected
Debian Bookworm / Mocha version 11.7.5 / Node version v24.11.0 -> do not work as expected

Additional Info

I have the same problem on other node versions (Debian Buster/Node 16 v16.20.2), so I guess it's mocha related.

The behavior has change between mocha@8.2.1 and mocha@8.3.0.
As I still have the same problem with mocha@11.7.5, it is in all versions since v8.3.0.

For me it looks very similar to issue: #3951

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: reportersinvolving a specific reporterstatus: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions