Skip to content

fix: give CLI reporter-option precedence over config file - #6331

Merged
mark-wiemer merged 2 commits into
mochajs:mainfrom
Minouccc:fix/reporter-option-cli-override-v2
Sep 17, 2026
Merged

mark-wiemer merged 2 commits into
mochajs:mainfrom
Minouccc:fix/reporter-option-cli-override-v2

Conversation

@Minouccc

@Minouccc Minouccc commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

--reporter-option given on the CLI lost to the same key declared in an RC file or package.json. This PR makes reporter-option values accumulate in priority-LOW to HIGH order so the CLI value wins. Other array options keep the existing behavior.

Tests

  • added e2e coverage: CLI --reporter-option now overrides a clashing key from .mocharc.yml while keeping non-clashing config values
  • unit tests cover the merged order across package.json / rc / env / CLI sources
  • full node unit suite, lint, tsc and format checks pass

In mergeConfigObjects, array options from higher-priority sources were prepended ahead of lower-priority ones. Downstream coerceReporterOption reduces with last-writer-wins semantics, so the config file value won over the CLI value. reporter-option values now accumulate in priority-LOW to HIGH order; every other array option keeps the existing order.

Fixes mochajs#5532.
@github-actions

Copy link
Copy Markdown
Contributor

Mixed activity

Activity patterns show a mix of organic and automated signals.

View full analysis →

Evidence
  • Multiple forks: 6 repositories forked in a single 24-hour window

This is an automated analysis by AgentScan

@github-actions

This comment has been minimized.

@mark-wiemer mark-wiemer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.34%. Comparing base (6728030) to head (0f4e606).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6331      +/-   ##
==========================================
+ Coverage   63.30%   63.34%   +0.03%     
==========================================
  Files          64       64              
  Lines        4963     4965       +2     
  Branches     1124     1125       +1     
==========================================
+ Hits         3142     3145       +3     
+ Misses       1821     1820       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mark-wiemer
mark-wiemer merged commit 571110f into mochajs:main Sep 17, 2026
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants