-
-
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
unable to require('when') (cujojs/when) in test #216
Comments
https://github.com/cujojs/when/blob/master/when.js#L22 I'm pretty sure |
I get into the same trap, thanks to @wwalser it's was easy to get out. Maybe it will be clearer as a draw: The module i'm testing is A. When testing it, i'm expecting B to be mocked and not to require C for real. A -> mock(B) -> B -> mock(C) -> C Is this because of the automatic construction of the mock ? Also, it seems to me that the doc pointed by @wwalser has some syntaxe issue, |
It sounds like you've already caught on to what is happening, your illustration is close to accurate. Actually the real requires of b and c happen before the mock can be constructed. They are required into a sandboxed context and inspected in order to create a mocked version. It's expected behavior. In every case that I've seen this is only a problem when simply requiring a module causes side effects which I tend to treat as an antipattern in my own code. |
I've added |
This will be fixed in 0.9.0. You can try it with |
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. |
Hello!
My test file is as simple as
but still throws error even if i disable mocking using jest.dontMock('when')
Is there any workaround?
The text was updated successfully, but these errors were encountered: