Test files run through node --test
seem to use a shared ESM cache (which is not expected and also not very practical)
#44595
Labels
test_runner
Issues and PRs related to the test runner subsystem.
Version
v18.8.0
Platform
Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64
Subsystem
test runner
What steps will reproduce the bug?
As referenced in #44583,
node --test
appears to run each test file against a single shared ESM cache. This is not only impractical, but also unexpected. The Node docs explicitly state that “each matching test file is executed in a separate child process”, which suggests that each of them runs in a fresh environment.This does not seem to be the case, as evidenced by the following test case:
This will run two test files, each of them importing the same dependency. If they would use separate ESM caches, the
imports
array would be filled with two entries instead of one, in which case one of the test files would throw an error. As you can witness from running this, no error is being thrown which means that the shared dependency is imported only once.How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
Test run should fail if separate ESM caches are used.
What do you see instead?
Test run does not fail.
Additional information
No response
The text was updated successfully, but these errors were encountered: