Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes runtime errors that occur when running tests with --isolate false mode. The key issue was that certain global state (snapshot clients, spy infrastructure) was not properly managed when tests share the same runtime context.
Key Changes:
- Refactored spy infrastructure to be properly scoped within an
initSpy()function, allowing state to be shared correctly in no-isolate mode - Moved snapshot client from module-level singleton to
workerState, enabling proper lifecycle management - Added fallback to
latestAssetFilesin module loaders to handle dynamic asset file resolution in non-isolated contexts
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types/worker.ts | Added optional snapshotClient property to WorkerState type and imported SnapshotClient type |
| packages/core/src/runtime/worker/loadModule.ts | Moved latestAssetFiles declaration to top of file and added fallback lookup for asset files |
| packages/core/src/runtime/worker/loadEsModule.ts | Added fallback to latestAssetFiles for asset file resolution in dynamic imports |
| packages/core/src/runtime/worker/index.ts | Made createRstestRuntime call async with await |
| packages/core/src/runtime/runner/index.ts | Changed to use workerState.snapshotClient instead of calling getSnapshotClient() |
| packages/core/src/runtime/api/utilities.ts | Made createRstestUtilities async and dynamically imports spy utilities |
| packages/core/src/runtime/api/spy.ts | Wrapped all spy state and functions in initSpy() to properly scope state for no-isolate mode |
| packages/core/src/runtime/api/snapshot.ts | Moved snapshot client initialization into SnapshotPlugin and stores in workerState |
| packages/core/src/runtime/api/index.ts | Made createRstestRuntime async and updated function signatures |
| package.json | Added test:no-isolate to e2e test script |
| e2e/spy/invocationCallOrder.test.ts | Added test for restoreAllMocks() behavior with persistent call order in no-isolate mode |
| e2e/snapshot/extend.test.ts | Changed to use expect as a fixture parameter instead of global import |
| e2e/package.json | Added test:no-isolate script for testing without isolation |
| e2e/mock/tests/resetModules.test.ts | Added afterAll cleanup and changed imports to use dedicated test module |
| e2e/mock/tests/mockTypedArg.test.ts | Added afterAll hook to unmock modules for no-isolate test cleanup |
| e2e/mock/tests/importActual.test.ts | Added afterAll hook to unmock modules for no-isolate test cleanup |
| e2e/mock/tests/doMock.test.ts | Added afterAll hook to unmock increment module for no-isolate test cleanup |
| e2e/mock/src/testResetModule.ts | New test module file for resetModules test isolation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
fix some runtime errors when no isolate
Related Links
fix #777
Checklist