-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
'There are multiple mobx instances active' error caused by jest mocks #1672
Comments
This seems to be caused by jestjs/jest#4940, if I you add a
|
You can now upgrade to MobX 4.4 / 5.1, which can work around this error |
@mweststrate still get this error even after upgrading to version 5.1 I want to unit test a model build with mobx-state-tree and have the same error. |
Please open a new issue with small reproduction. Similar symptoms are not
necessarily the same cause.
Op ma 27 aug. 2018 22:51 schreef Emanuel Quimper <[email protected]>:
… @mweststrate <https://github.com/mweststrate> still get this error even
after upgrading to version 5.1 I want to unit test a model build with
mobx-state-tree and have the same error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1672 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhNdEPRjcIfGbjiYMeWXYChCNEpstks5uVFvUgaJpZM4V1WXW>
.
|
@mweststrate I just make it work, in react-native I put globals window: true when it should be an empty object. Sorry for this |
This used to be a warning in previous mobx versions, on the latest mobx versions it straight out crashes. I will raise the issue with an example test/demo. |
I think more people will run into this or already did, perhaps we can discuss the solution. This is a question / issue that I have met while upgrading mobx 3.3 to 4.3. It's of course possible this is more a Jest problem rather than MobX, but I'm posting here for better visibility.
I'm using Jest 23 for tests and after the upgrade, when I run the tests, I get:
Error: [mobx] There are multiple mobx instances active. This might lead to unexpected results. See https://github.com/mobxjs/mobx/issues/1082 for details.
I only encounter the problem when running tests. The problem stems from
jest.genMockFromModule
(and possibly Jest's other mocking mechanisms). It is reproducible by creating a mock of a module that imports from mobx. A minimal repro is here - just clone it, install and run npm t.Solution
I'm still looking for a proper one. I have tried using
in the setup file but it seems like there is some sort of asynchronous behavior involved - it does improve things, but fails with the same error at some point.
Any pointers appreciated. Thanks!
The text was updated successfully, but these errors were encountered: