Skip to content

fix: use find-up-simple to workaround ERR_PACKAGE_PATH_NOT_EXPORTED - #6342

Merged
mark-wiemer merged 10 commits into
mainfrom
fix-exports-err
Sep 17, 2026
Merged

mark-wiemer merged 10 commits into
mainfrom
fix-exports-err

Conversation

@mark-wiemer

@mark-wiemer mark-wiemer commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

PR Checklist

Overview

Validated using the new repro folder, see commit history. Will add a proper test as part of #6341 .

Order is respected in the same way as find-up respects order.

@mocha-github-app mocha-github-app Bot added this to Mocha Sep 16, 2026
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6342      +/-   ##
==========================================
+ Coverage   63.30%   63.35%   +0.04%     
==========================================
  Files          64       64              
  Lines        4963     4969       +6     
  Branches     1124     1101      -23     
==========================================
+ Hits         3142     3148       +6     
  Misses       1821     1821              

☔ 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

Copy link
Copy Markdown
Member Author

@copilot Incorporate the tests suggested in #6345

Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

CLA Not Signed

@mark-wiemer

Copy link
Copy Markdown
Member Author

@copilot use GPT-5.6 Terra, think deeply, and create a test that would fail on main but pass on this branch that uses something very similar --import=tsx. Report in a comment which tests came closest. We want to be able to catch issues like the backing one with automated tests.

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@copilot Incorporate the tests suggested in #6345

Implemented in e6dcbe2.
Added the requested tests in test/node-unit/cli/config.spec.cjs for:

  • config filename search order
  • stopping after first found match
  • returning undefined when no config is found

Also validated with npm run -s test-node-run -- test/node-unit/cli/config.spec.cjs.

Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@copilot use GPT-5.6 Terra, think deeply, and create a test that would fail on main but pass on this branch that uses something very similar --import=tsx. Report in a comment which tests came close...

Done in f0490c1.

Added a regression test in test/integration/options/node-flags.spec.cjs plus import-hook fixture test/integration/fixtures/options/node-flags/import-break-find-up.mjs. It uses --node-option import=... to simulate the --import=tsx-style startup resolution failure path and verifies Mocha still runs tests.

Closest existing tests I found were:

  • test/integration/options/reporter-option.spec.cjs (node-option + respawn + config flow)
  • test/integration/options/node-flags.spec.cjs (node-option forwarding)
  • test/integration/esm.spec.cjs (loader/module-resolution error assertions)
  • test/node-unit/cli/{config.spec.cjs,options.spec.js} (config/package discovery paths)

@mark-wiemer

Copy link
Copy Markdown
Member Author

@copilot failing on windows consistently

Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@copilot failing on windows consistently

Fixed in b021ff4.

I checked the failing Windows CI logs (Tests run 35098596052, integration jobs) and the failure was ERR_UNSUPPORTED_ESM_URL_SCHEME from --node-option import=D:\....

I updated the test to pass a file:// URL via pathToFileURL(...).href and increased the test timeout to 5s for startup variance.

@mark-wiemer
mark-wiemer merged commit a652ff5 into main Sep 17, 2026
98 of 99 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Mocha Sep 17, 2026
@mark-wiemer
mark-wiemer deleted the fix-exports-err branch September 17, 2026 13:33
@8rulerstar 8rulerstar mentioned this pull request Sep 18, 2026
3 tasks done
@43081j

43081j commented Sep 21, 2026 •

Copy link
Copy Markdown

While this is a win, it is unfortunate that the months of discussion around switching to empathic have seemingly been ignored here.

find-up-simple offers nothing over it and just causes ecosystem fragmentation. exactly why we were trying to switch to empathic instead - the library everyone else uses.

would you be open to switching it? we shouldn't use downloads as a stat by itself, but ~23M vs ~9M shows you why this is a strange decision.

here you go:
main...43081j:mocha:jg/empathic-again

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 Bug: ERR_PACKAGE_PATH_NOT_EXPORTED in Mocha 12.0.1 with --import=tsx

3 participants