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

Never unhook .node modules #6

Closed
cspotcode opened this issue Dec 10, 2015 · 0 comments
Closed

Never unhook .node modules #6

cspotcode opened this issue Dec 10, 2015 · 0 comments
Labels

Comments

@cspotcode
Copy link
Owner

Native .node modules cannot be loaded more than once.

require('./some-lib.node');
delete require('module')._cache[<some-lib's module ID>];
require('./some-lib.node');
// Error: Module did not self-register.

Mockery will have to cache native modules no matter what, so that they're never loaded more than once. They can still be substituted and mocked. The only problem is if a native module require()s some dependencies, but I don't think that happens in practice.

See also: mfncooper#34

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

No branches or pull requests

1 participant