-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose parts of runtime for dynamic module loading #10069
Comments
We usually write to temp dirs when testing things like these. Admittedly though, this may be a significant slowdown on Win/Mac. |
A modified |
Override - I view it similarly to how we have a custom |
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
Thanks a lot for offering to implement this ❤️ I've left a comment over there |
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
Hook into the jest module loading mechanisms for the `Module#_compile` functionality provided by Node. Fixes jestjs#10069.
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Expose enough functionality from the runtime to allow dynamically constructing a module (and optionally loading it into the module registry) from generated source.
In particular, this would involve a new function (e.g.
jest.loadModuleFromSource
) that hooks into_execModule
with a little additional glue to create theInitialModule
.Motivation
When testing bundler-related functionality, it can be useful to evaluate the generated source and check its validity against a well-defined module implementation. It's possible to do this currently by instantiating a
Module
from the builtinmodule
module (ahem) and using_compile
, but this doesn't get access to the currenttestEnvironment
(i.e. there's nodocument
available in the dynamically loaded module underjsdom
).Example
Please provide an example for how this feature would be used.
Pitch
There doesn't appear to be much public API surface that allows more complex interactions with the runtime or the module registry. It'd be nice to support additional use-cases in testing dynamically generated code that don't seem to currently be supported.
Happy to take a stab at the implementation if y'all think this is a feature worth of the jest platform.
The text was updated successfully, but these errors were encountered: