-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Global state does not reset for C++ addons #2826
Comments
Can you setup a brief repro of the issue? |
I'm not sure if these can be unloaded. |
@cpojer You may be right as this seems related to: nodejs/node#5016. However, without unloading the binary, it might still be possible to revert the state of the JS object returned. |
I don't think we are able to do so, as you pointed out in the node.js issue you linked to. |
Maybe it's worth to close it and reopen when the issue is resolved on Node side? I think this is something we would like to know works with Jest |
Yeah I'm gonna close this out for now. If anybody has creative ideas on how to solve this, please let me know. |
Perhaps you can offer suggestions on what might be a workaround? This is causing me a lot of issues. A suitable workaround would be a way to be able to require the module once and pass a reference to the tests without re-requiring it. I tried a custom test environment, but that was a no-go. Right now this issue is completely preventing me from using Jest at all, so thoughts would be much appreciated. |
Yeah, it should work with a custom test environment as long as you only create one instance. Another solution could be to add a "__resetForTest" method to your native module that resets it in C++. |
I also encountered this problem and hope to have a solution. This problem makes me completely unable to use Jest at all. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
require()ing a native module across several tests does not reset that module's state
To reproduce, see: https://github.com/jingchan/jest-issue-2826
What is the expected behavior?
The module's state should be the same every time to match the description from https://facebook.github.io/jest/:
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
jest v18.1.0; node v7.5.0; npm v4.1.2; OSX Sierra & Windows 10
This is causing me issues when testing certain packages which wrap and replace the functions of the object returned from the require call. Any ideas for temporary workarounds would be welcome.
The text was updated successfully, but these errors were encountered: