-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
test_runner: add env option to run function #61367
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
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61367 +/- ##
=======================================
Coverage 88.51% 88.52%
=======================================
Files 704 704
Lines 208739 208786 +47
Branches 40274 40306 +32
=======================================
+ Hits 184770 184827 +57
+ Misses 15968 15956 -12
- Partials 8001 8003 +2
🚀 New features to boost your workflow:
|
Support an `env` option that is passed to the underlying child_process. Fixes: nodejs#60709
724b84e to
cd4d84e
Compare
| const args = getRunArgs(path, opts); | ||
| const stdio = ['pipe', 'pipe', 'pipe']; | ||
| const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' }; | ||
| const env = opts.env || { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' }; |
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.
NODE_TEST_CONTEXT is used by the test runner to identify the runner subprocesses, and removing it may cause issues with the reporters.
It must be preserved even if the user passes opts.env.
I would suggest, in any case, adding a snapshot test when using this option to cover the E2E once the option has been provided!
| * `functionCoverage` {number} Require a minimum percent of covered functions. If code | ||
| coverage does not reach the threshold specified, the process will exit with code `1`. | ||
| **Default:** `0`. | ||
| * `env` {Object} Specify environment variables to be passed along to the test process. This options is not compatible with `isolation='none'`. |
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 it might be worth specifying here that these variables will override those from the main process
Support an
envoption that is passed to theunderlying child_process.
Fixes: #60709