fix: setup files run only once with no-isolate#947
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical issue in no-isolate mode where setup files and their dependencies were only executed once across multiple test files due to module caching. The fix clears the module cache after each test file completes, ensuring setup files re-execute for every test file.
Changes:
- Removed the
latestAssetFilesworkaround that attempted to address stale asset references but didn't solve the underlying module caching issue - Added
clearModuleCache()exports to bothloadModule.tsandloadEsModule.tsto clear the internal module caches - Modified
runInPoolteardown to callclearModuleCache()after each test file completes
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/runtime/worker/loadModule.ts | Removed latestAssetFiles workaround; added clearModuleCache export to clear moduleCache |
| packages/core/src/runtime/worker/loadEsModule.ts | Removed latestAssetFiles workaround; added clearModuleCache export to clear esmCache |
| packages/core/src/runtime/worker/index.ts | Removed updateLatestAssetFiles call; added clearModuleCache call in teardown |
| e2e/setup/index.test.ts | Added test case to verify setup files run once per test file in no-isolate mode |
| e2e/setup/fixtures/no-isolate/rstest.setup.ts | New test fixture with beforeAll/afterAll hooks to verify re-execution |
| e2e/setup/fixtures/no-isolate/rstest.config.ts | Config for no-isolate test with isolate:false and maxWorkers:1 |
| e2e/setup/fixtures/no-isolate/foo.test.ts | Test file verifying setup file effects and snapshot serializer |
| e2e/setup/fixtures/no-isolate/bar.test.ts | Second test file verifying setup runs again |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
9aoy
approved these changes
Feb 6, 2026
Collaborator
|
👍 |
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.
Summary
In no-isolate mode, the module cache can cause several issues:
assetFilesin [Bug]: Set isolate option to false causes some errors #777 ordocument.bodyintesting-libraryThis PR adds a step to clear the module cache after each test file finishes running.
Related Links
Checklist