| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The previous implementation was trying to follow both `require` and `import` conventions. It is not practical to try to follow both, and aligning with `import()` seems to be what makes the most sense.
|
Review requested:
|
Sorry, something went wrong.
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files @@ Coverage Diff @@
## main #54416 +/- ##
==========================================
- Coverage 87.33% 87.32% -0.01%
==========================================
Files 648 648
Lines 182321 182324 +3
Branches 34971 34980 +9
==========================================
+ Hits 159222 159223 +1
+ Misses 16374 16373 -1
- Partials 6725 6728 +3
|
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM (sans the lint errors obv)
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
The previous implementation was trying to follow both `require` and `import` conventions. It is not practical to try to follow both, and aligning with `import()` seems to be what makes the most sense. PR-URL: #54416 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This behavior is since nodejs/node#54416. It is in v22 since v22.8.0 (nodejs/node#54560), v24 since v24.0.0, and v25 since v25.0.0. It's not in v22. Relevant Nodejs code: https://github.com/nodejs/node/blob/ae2ffce5f3d5ac5ad153d98839d5a19a70e073b2/lib/internal/test_runner/mock/mock.js#L619-L625 Relevant Nodejs test: https://github.com/nodejs/node/blob/ae2ffce5f3d5ac5ad153d98839d5a19a70e073b2/test/parallel/test-runner-module-mocking.js#L158-L160
This behavior is since nodejs/node#54416. It is in v22 since v22.8.0 (nodejs/node#54560), v24 since v24.0.0, and v25 since v25.0.0. It's not in v22. Relevant Nodejs docs: https://nodejs.org/docs/latest-v25.x/api/test.html#mockmodulespecifier-options Relevant Nodejs code: https://github.com/nodejs/node/blob/ae2ffce5f3d5ac5ad153d98839d5a19a70e073b2/lib/internal/test_runner/mock/mock.js#L619-L625 Relevant Nodejs test: https://github.com/nodejs/node/blob/ae2ffce5f3d5ac5ad153d98839d5a19a70e073b2/test/parallel/test-runner-module-mocking.js#L158-L160
| Back | FazBrowse Home | New Git URL |
The previous implementation was trying to follow both require and import conventions. It is not practical to try to follow both, and aligning with import() seems to be what makes the most sense. It would allow us to greatly simplify the internal loader.
For Unix paths, it barely makes a difference (only if the path contains special URL chars such as ?, #, or %). For Windows, it means you need to use / instead of \ for path delimiter, and escape any # or % char. In my experience, folks really only mock either relative paths, or bare specifiers (i.e. module from a node_modules package), so I don't expect this change to be breaking.
Refs: #54223 (comment)