Closed tandrewnichols closed 10 years ago
Indeed, sandboxed modules are completely sandboxed; objects in them live in a different global context, with different prototypes etc.
I forgot this was still open. Yeah, I actually realized that later, as I looked at what vm
is doing. Thanks.
I tried to browse the code to see what exactly, but I decided it would be faster to surface the issue here and see if it's expected behavior. Maybe I'm just using this module wrong (or misunderstanding something).
I've noticed that some testing frameworks have problems in conjunction with this module. See this gist for an example: https://gist.github.com/tandrewnichols/9446085.
Below is the output from running npm test on that code (minus stack traces):
Changing
sandbox 'fooBar'
torequire './fooBar'
makes the code pass. Also, wrapping@subject.foo
and@subject.bar
inJSON.parse(JSON.stringify(...))
makes them pass. Is some additional property being added that would make traditional comparisons fail?