-
Notifications
You must be signed in to change notification settings - Fork 42
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
instanceof Function broken inside of sandboxed module #44
Comments
I imagine this happens because globals are carried across from the outside of the sandboxed-module? Will |
@tristanls That works, but this is third party code. I don't want to have to fork every dependency that uses |
@OliverJAsh yes, I removed the comment :) |
Argh, this is frustrating. We copy over the globals because #13 (which was how I got involved in the project it looks like). There, the tests would do e.g. I am unsure how we could satisfy both situations. Maybe just offer an option, but that kind of sucks :(. |
This actually causes more subtle issues. Here's another example: sandboxed.js
test.js
This throws an error because |
@joshperry that's basically the definition of sandboxing, though. You aren't affected by modifications to the environment's prototypes; instead you run in your own clean sandbox. |
I'm having this issue as well. A quick and dirty workaround is to inject the dependency - so I was getting the issue with the moment date lib. test = sandboxedModule.require('filetotest', {
requires: {
'moment' : require('moment')
},
}); |
@elliotstokes Great idea. |
I ran into this again, this time without being able to work around it. My code was using Joi to do some validation: ...
thing: Joi.object().type(Map)
... and that runs again into the As @domenic pointed out before, this module sandboxes, and that works great for most tests as I've happily written hundreds of tests using this module. This is the only corner case I couldn't work around. For testing, using proxyquire resolved my |
I have a sandboxed module with the following contents:
foo instanceof Function
should returntrue
, but it returnsfalse
.The text was updated successfully, but these errors were encountered: