Skip to content

fix: apply config filename precedence per directory - #6454

Open
akasakariko wants to merge 1 commit into
mochajs:mainfrom
akasakariko:fix/6395-config-precedence-per-directory
Open

akasakariko wants to merge 1 commit into
mochajs:mainfrom
akasakariko:fix/6395-config-precedence-per-directory

Conversation

@akasakariko

@akasakariko akasakariko commented Oct 27, 2026 •

Copy link
Copy Markdown

PR Checklist

Issue #6395 is still labeled status: in triage, so the second item stays unchecked until a maintainer relabels it

Overview

Since 12.0.2, findConfig calls find-up-simple once per filename, so .mocharc.cjs is searched up to the filesystem root before .mocharc.js is looked for in the current directory. A parent .mocharc.cjs is loaded even when the working directory has its own .mocharc.js

findUpSyncAny now walks one directory level at a time and confines each filename lookup to that directory via stopAt. Filename priority applies only among files in the same directory. Parent lookup is unchanged when the current directory has no config file

Verification

  • npm run test-node: exit 0, including 1304 unit and 391 integration passing
  • eslint and prettier clean on the changed files
  • Manual repro from the issue: local .mocharc.js is now used, while 12.0.3 used the parent .mocharc.cjs

Tests

  • Updated the findConfig() unit tests to assert the per-directory search order
  • Added a regression test with a local .mocharc.js next to an ancestor .mocharc.cjs, which fails without the fix

lint:knip-docs still reports the pre-existing unused satteri dependency in docs/package.json

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA Not Signed

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

👋 Hi @akasakariko, thanks for the pull request! A scan flagged a concern with it. Could you please take a look?

[pr-task-completion] This PR's body is missing [x] checks on the following tasks from the PR template.

Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a [x] in the pull request description. Please complete those tasks and mark the checks as [x] completed.

🗺️ This message was posted automatically by OctoGuide: a bot for GitHub repository best practices.

@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: 7 repositories forked in a single 24-hour window

This is an automated analysis by AgentScan

findConfig searched the whole tree for each config filename in turn, so an
ancestor .mocharc.cjs won over a local .mocharc.js. Walk one directory level
at a time and confine each filename lookup to that directory

closes mochajs#6395
@akasakariko
akasakariko force-pushed the fix/6395-config-precedence-per-directory branch from 4e3f5df to a8ed7ac Compare October 27, 2026 13:24
@akasakariko

Copy link
Copy Markdown
Author

recheck

This branch has not been deployed

No deployments
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: ancestor .mocharc.cjs is chosen over a local .mocharc.js

1 participant