Skip to content

fix: some runtime errors when no isolate#787

Merged
9aoy merged 3 commits intomainfrom
no-isolate-runtime
Dec 22, 2025
Merged

fix: some runtime errors when no isolate#787
9aoy merged 3 commits intomainfrom
no-isolate-runtime

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Dec 18, 2025

Summary

fix some runtime errors when no isolate

Related Links

fix #777

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings December 18, 2025 13:19
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 18, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit b4e4708
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/6944041f22c96b000802f143
😎 Deploy Preview https://deploy-preview-787--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 latestAssetFiles in 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.

@9aoy 9aoy merged commit e36a728 into main Dec 22, 2025
16 checks passed
@9aoy 9aoy deleted the no-isolate-runtime branch December 22, 2025 03:00
@9aoy 9aoy mentioned this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Set isolate option to false causes some errors

2 participants