-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
test_runner: unify --require and --import behavior when isolation none #57924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: unify --require and --import behavior when isolation none #57924
Conversation
| Review requested:
|
599cf81 to f9472b6 Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W00t!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.