Skip to content

Conversation

@saranganet
Copy link
Contributor

@saranganet saranganet commented Nov 24, 2025

fixes #5532

Summary

Fixes the regression where command-line --reporter-options parameter doesn't override .mocharc.yml settings. This issue was introduced in v8.3.0.

Changes Made

  • Modified lib/cli/options.js:
    • Moved command-line args to the end of config objects list for higher priority
    • Added special handling for reporter-option to detect CLI usage and override config file values
  • Added comprehensive tests in test/cli/options-reporter-option-override.spec.js

Test Coverage

The fix handles all scenarios:

  • CLI options override config file
  • Both --reporter-options and --reporter-option aliases work
  • Both space-separated and = syntax work
  • Multiple CLI options use the last one
  • Config file options work when no CLI is provided

Verification

# Test with config file having: reporter-options: ['output=./test-reports/xunit.xml']
mocha --reporter-options output=./test-reports/cli.xml
# Should create cli.xml, not xunit.xml

@mark-wiemer mark-wiemer changed the title Fix/reporter options override #5532 fix: reporter options override Nov 25, 2025
@mark-wiemer
Copy link
Member

@saranganet thanks for the PR, please review the failing checks :)

@mark-wiemer mark-wiemer added the status: waiting for author waiting on response from OP or other posters - more information needed label Nov 25, 2025
- Move command-line args to end of config objects list for higher priority
- Add special handling for reporter-option to ensure CLI overrides config file
- Add comprehensive tests for all scenarios
- Fixes regression introduced in v8.3.0
- Move command-line args to end of config objects list for higher priority
- Add special handling for reporter-option to ensure CLI overrides config file
- Add comprehensive tests for all scenarios
- Fixes regression introduced in v8.3.0

Resolves: mochajs#5532
- Fixes issue with reporter options not being properly merged
- Handles multiple --reporter-option flags correctly
- Ensures CLI options override config file options
- Fixes mochajs#5532
@saranganet saranganet force-pushed the fix/reporter-options-override-5532 branch from 54b0701 to 85fda87 Compare November 25, 2025 18:04
…ion for reporter option format\n- Ensure 'key=value' format is enforced\n- Improve error messages for invalid formats\n- Fixes mochajs#5532
…ensure consistent code style\n- Fix reporter option validation format\n- Ensure all tests pass locally
@saranganet
Copy link
Contributor Author

@mark-wiemer , the tests are passing locally, but when I am trying to push then its failing. Anyone else can help fix the push then please ping me.

@JoshuaKGoldberg
Copy link
Member

when I am trying to push then its failing

If you want help you'll need to be a little more specific 🙂. Just a simple "its failing" isn't enough info for us to know how to help you. What's failing? What are the errors you're seeing? What have you tried? What do you think is going on?

Suggestions:

  1. Take a look at the ❌ failures noted in this PR
  2. Read through and try to understand them, including Googling / asking AI / whatever you personally prefer for debugging
  3. Try a few different strategies to resolve them
  4. Repeat 1-3 for every different kind of issue you're getting
  5. If 1-4 don't work, tell us precisely what's going on and ask for help - we'd be happy to take a look

"semver": "^7.7.2",
"sinon": "^9.0.3",
"typescript": "^5.8.3",
"typescript": "^4.9.5",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, and not one we want in this PR. We don't want to downgrade the TypeScript dependency. Did this sneak in from some local testing, or maybe some odd merge conflict?

This PR will need to revert changes to package.json, package-lock.json, and .gitub/release-please/manifest.json. These files aren't necessary to change for this PR's intended purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting for author waiting on response from OP or other posters - more information needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants