test_runner: support mocking non-existent modules#62298
test_runner: support mocking non-existent modules#62298geeksilva97 wants to merge 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
5d7b662 to
c1881e2
Compare
There was a problem hiding this comment.
if it does exist on disk, though, it could be imported/required via other means, so it seems prudent to ensure the actual resolved specifier is still mocked out?
There was a problem hiding this comment.
That's an edge case I could not think of. Would you have an example to illustrate the issue?
There was a problem hiding this comment.
Let's say you have an exports specifier "foo": "./foo/index.js" in package pkg.
That can be required, or imported, by any of the following paths relative to the package root:
pkg/foo./foo/index.js./foo(if it's a CJS file)./foo/index(if it's a CJS file)
If you don't fully resolve to a list of potential paths and confirm that, in fact, nothing exists in any of them, then shadowing a subset of them would create a scenario where you have more than one source of truth about that resource's contents.
There was a problem hiding this comment.
Thank you so much for the example, @ljharb . It makes so much sense.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62298 +/- ##
==========================================
- Coverage 89.77% 89.69% -0.08%
==========================================
Files 673 676 +3
Lines 203820 206777 +2957
Branches 39175 39605 +430
==========================================
+ Hits 182987 185477 +2490
- Misses 13152 13439 +287
- Partials 7681 7861 +180
🚀 New features to boost your workflow:
|
Fixes #55891