-
-
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
Jest and Mongoose not working well together #3045
Comments
What does the test look like? Which OS do you use? can you provide a repro? |
@thymikee - the test file looks like the code snippet above and it reproduces the problem. I can wrap it inside I am using MacOS Sierra 10.12.3 (latest). And a clean |
You must wrap it with |
I'll create a repository, wrapping it back into a test (I unwrapped it for the sake of simplicity). |
@thymikee - there you go: https://github.com/jozsi/bug-jest-mongoose |
This is not a bug in Mongoose, nor in Jest. Your test is just wrong. Please take a look at resources on how test Mongoose. I believe there's no good article on how to pair it with Jest, but there's something for Jasmine: http://www.mattritter.me/?p=1 and a lot for Mocha (which should work for Jest too without many changes), so there's a lot to pick ideas from. Good luck! :) |
@thymikee - I am not trying to test the index creation. I do need the index to be created in order for some real world tests to work, but it doesn't because the creation fails in under the jest environment, while works under node, mocha or any other environment. I'll update the repo with a test that's just not wrong:
|
Try changing |
@thymikee - thank you, setting So I need to provide a separate environment for the Node.js and React parts of my app (I suppose it would be the best to run React tests under |
Yea, this is a pain right now and we're working on multi-config runner to solve this exact problem. |
@thymikee - thanks for heads-up! Meanwhile I've updated the test and opened a jsdom issue - maybe it will resolve the environment inconsistency. Will keep you posted once I hear from them or Mongoose devs. |
Mongoose has been fixed (starting v4.9.1) to work correctly with Jest. The underlying |
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. |
Using the latest version of Jest (
19.0.2
) and Mongoose (4.8.5
), the following code is breaking when ran by jest:Expected result (when ran by Node.js (
7.6.0
)):Actual result (when ran by Jest):
I am using the default jest configuration (=> automocking is disabled).
Related: Automattic/mongoose#5033
The text was updated successfully, but these errors were encountered: