test_runner: scope file-level hooks per file in no-isolation mode#62615
Draft
marcopiraccini wants to merge 1 commit intonodejs:mainfrom
Draft
test_runner: scope file-level hooks per file in no-isolation mode#62615marcopiraccini wants to merge 1 commit intonodejs:mainfrom
marcopiraccini wants to merge 1 commit intonodejs:mainfrom
Conversation
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
Collaborator
|
Review requested:
|
Contributor
Author
|
Not sure this is the correct approach, though. This gives a nesting level to every test automatically, channging the ouput. Mark as draft, will amend. |
Member
|
Hey @marcopiraccini, thanks for your contribution! The current behavior is actually expected. That said, it seems we have different perspectives on it, and it would be worth discussing further before considering such a significant breaking change. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62615 +/- ##
==========================================
- Coverage 89.75% 89.74% -0.01%
==========================================
Files 696 696
Lines 214812 214807 -5
Branches 41108 41104 -4
==========================================
- Hits 192801 192787 -14
- Misses 14120 14125 +5
- Partials 7891 7895 +4
🚀 New features to boost your workflow:
|
MoLow
reviewed
Apr 6, 2026
| isolation mode is `'process'`. This flag is ignored if the `--test` flag is not | ||
| present. See the [test runner execution model][] section for more information. | ||
| `'none'`, all test files run in the same process as the test runner. Each test | ||
| file is wrapped in an implicit suite, so that lifecycle hooks such as |
Member
There was a problem hiding this comment.
this is an implementation detail, I dont think it needs documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
--test-isolation=none,beforeEach/afterEach/before/afterhooks declared at the top level of a test file were added to the root test and leaked into tests from other files. This is inconsistent with--test-isolation=process(the default), where each file runs in its own process and hooks are naturally scoped.This PR wraps every test file in an implicit suite when using
isolation: 'none', so that top-level hooks are scoped to their file. Wrapping is unconditional because hooks are registered at load time and we cannot know ahead of loading whether a file declares any.Global hooks registered via
--importor--requirecontinue to apply to all tests.NOTE: Updated existing no-isolation tests: the previous assertions expected hooks to leak across files (e.g.
beforeEachfromone.test.jsrunning for tests intwo.test.js). Updated to match the new scoped behavior, including the additional implicit file suites in pass/suite counts.Fixes: #61854