Closed studioph closed 2 years ago
second this issue. rewire
function can have an optional parameter to pass in variables. For example,
const target = rewire('./target', { toOverride: 'value' })
I'm sorry, this is out of scope of the current design. The module needs to be evaluated in order to change the internals. Fixing or changing this would require a major rewrite.
Is it possible to set the value of a variable at the same time as rewiring? I have this code:
and would like to be able to override the
mymodule
variable when callingrewire
so that the variable is defined with a mock, and doesn't try to load it fromnode_modules
.If this isn't possible with rewire, if anyone has any resources on how I could achieve this I would be most appreciative.
Thanks!