Skip to content

Add tests for using modules from script code run via Evaluate#2712

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:dynamic-import-script-tests
Jul 20, 2026
Merged

Add tests for using modules from script code run via Evaluate#2712
lahma merged 1 commit into
sebastienros:mainfrom
lahma:dynamic-import-script-tests

Conversation

@lahma

@lahma lahma commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds test coverage for the patterns that answer discussion #1472 ("Cannot use import/export statements outside a module" — how to use modules from code run via Evaluate):

  • CanDynamicallyImportFromScriptCode — dynamic import() inside a classic script resolves modules registered via Modules.Add, without EnableModules or a script source location. This path had no coverage; existing script-side dynamic import tests all use custom module loaders with explicit source: parameters.
  • CanAwaitDynamicImportFromScriptCode — same via await import() in an async IIFE.
  • CanExposeModuleNamespaceToScriptCode — importing a module from .NET and exposing its namespace object as a global for Evaluate-based code.

No production code changes.

Test plan

  • dotnet test --configuration Release Jint.Tests --filter "FullyQualifiedName~Jint.Tests.Runtime.ModuleTests" — 57 passed (net10.0 and net472)

🤖 Generated with Claude Code

Covers the patterns discussed in sebastienros#1472: dynamic import() inside a classic
script (both .then and await forms) resolving modules registered via
Modules.Add without EnableModules, and exposing an imported module
namespace as a global for Evaluate-based code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lahma
lahma enabled auto-merge (squash) July 20, 2026 17:55
@lahma
lahma merged commit c0f092e into sebastienros:main Jul 20, 2026
4 checks passed
@lahma
lahma deleted the dynamic-import-script-tests branch July 20, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant