Skip to content
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

const's and throws #18

Open
edsharp opened this issue Feb 18, 2016 · 0 comments
Open

const's and throws #18

edsharp opened this issue Feb 18, 2016 · 0 comments

Comments

@edsharp
Copy link

edsharp commented Feb 18, 2016

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:

  1. private const's aren't available unless I change them to var's
  2. 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant