test_runner: unify --require and --import behavior when isolation none#57924
test_runner: unify --require and --import behavior when isolation none#57924nodejs-github-bot merged 3 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
599cf81 to
f9472b6
Compare
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Thanks for picking this up!
lib/internal/test_runner/runner.js
Outdated
| const userModules = [ | ||
| ...getOptionValue('--require'), | ||
| ...getOptionValue('--import'), | ||
| ]; |
There was a problem hiding this comment.
I think the approach here is logical in terms of steps. But 2 caveats:
CascadedLoader(akaESMLoaderakaModuleLoader) does not handle CJS modules exactly the same asCJSLoader; if we're in ESM mode, this is "correct" (ESMLoader should handle it); but if not ESM mode, for good or ill, it could lead to unexpected behaviour.- Does this prevent the
--required module(s) executing prior to this? If not, they could be stateful or something else crazy which would get lost when the clone gets created here.
There was a problem hiding this comment.
Thanks for your review, @JakobJingleheimer 🚀
Regarding nr1: ok! I suspected that. I'll take a look to understand if we can just use the default method we're using for --require in the "default" entry point.
nr2: Yes, it prevents the default handling of --require from happening, it's now being executed only at this point!
There was a problem hiding this comment.
I've updated the logic to use loadPreloadModules and applied the other suggestions.
Before marking this PR as "ready to be reviewed", I'd like to ask you to take another look at these changes 😁
f9472b6 to
a2134be
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #57924 +/- ##
==========================================
- Coverage 90.26% 90.19% -0.07%
==========================================
Files 630 630
Lines 185933 186470 +537
Branches 36450 36624 +174
==========================================
+ Hits 167829 168186 +357
- Misses 10972 11061 +89
- Partials 7132 7223 +91
🚀 New features to boost your workflow:
|
|
Landed in 7e24ebc |
PR-URL: #57924 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
|
This doesn't land cleanly on v22.x-staging so a manual backport will be necessary if this is to be released there. |
I'm opening this PR as a draft to discuss the implementation.
The goal is to address issue #57728.
This PR unifies the behaviour of
--requireand--importfor the specific case where the test runner is run with isolationnone.