-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I've been comparing using rewire and mocks to see which best suits my needs.
Using node 5.6.0, I've noticed two things when using loadFile on a module:
- private const's aren't available unless I change them to var's
- private functions that throw errors don't seem to throw the same type of error as they do when they natively throw the error
I think 1. is caused because vm.runInNewContext does not seem to make the const's available on the context.
I'm not sure what causes 2.---although I suspect it's related to the 'displayErrors' option for runInNewContext---but the symptom is that:
// in module being loadFile'd
myFunc() {throw new Error('foo')}
// in test
should.Throw(myFunc(), Error, 'foo')will not assert.
I'm not sure if there's anything that can easily be done about either of these, but I thought I'd bring them to your attention and I'm curious to hear your answers :)
Metadata
Metadata
Assignees
Labels
No labels