Repository navigation
fix: show require() error on unsupported directory import - #6354
Merged
Merged
Conversation
mostafaNazari702
force-pushed
the
dir-import
branch
from
September 17, 2026 15:32
296e10e to
30456be
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6354 +/- ##
==========================================
+ Coverage 63.38% 63.44% +0.05%
==========================================
Files 64 64
Lines 4971 4973 +2
Branches 1102 1127 +25
==========================================
+ Hits 3151 3155 +4
+ Misses 1820 1818 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5 tasks done
mark-wiemer
approved these changes
Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
status: accepting prsOverview
When loading a test file fails both ways mocha now shows the require() error if import() only failed with ERR_UNSUPPORTED_DIR_IMPORT. That error just means import() hit a folder path require() handles fine so you would see "Directory import is not supported" instead of the missing module or compile error you were actually after.
As i did mention in the backing issue this doesn't reproduce on main right now because #5498 only landed on Mocha v11.x so the
||from #5408 is still here and a .ts file on its own picks the require() error by luck. Put the && back and the bug returns which is why i made this its own check instead of folding it into that condition.and i left the forward port alone since it needs the ".....with a loader" test sorted out too and didnt touch the "show both errors" work in #5235.