-
-
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
Removes error when mocking mongoose library root object #8040
Conversation
…s interaction with mongoos
Resolves #3073 |
Thanks! Would be great to add a test for this. If all existing tests pass, maybe an integration test that has I merged in master to fix the conflict |
Does this makes us closer to fix the awful recommendation not to use Jest on their docs maybe? https://mongoosejs.com/docs/jest.html |
Wow, harsh :P Hadn't seens the article. Would have been nice if they reached out first... Meh, not gonna spend any energy on it |
I'm super curious to know which truthy value that is not an object breaks when assigning to it |
Yeah, just a property called This reproduces const jestMock = require('jest-mock');
const metadata = jestMock.getMetadata({prototype: 1});
jestMock.generateFromMetadata(metadata); throws:
|
I pushed that as a test :) |
Beat me to it! 😜 |
Interestingly, it does not work only on
I guess I'm too old-school by now 😄 |
Thanks @hluedeke! |
Hey guys so this comment won't bring anything useful for the conversation, but I just wanted to let you know that because of this we finally can upgrade from mongoose v4.7.0, I've just ran our test suite successfully, and I couldn't be happier today. Thanks a lot everyone involved, and thank you @hluedeke !!! You really, really made my day. And kuddos for the fast release. I can't stress enough how it was for me to land on this old issue in our repo, land on this, see "Closed", then see "3 days ago" then go on the PR and see it's merged, and see it's released. Pure joy. Cheers 🎉 |
Agreed, this was an A+ open source experience! Huge thanks to both @hluedeke and the maintainers for such a quick and friendly fix. Y'all are amazing! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Allows mongoose library to be mocked using jest.mock('mongoose') without the error:
TypeError: Cannot create property 'constructor' on number '1'
Test plan
Used linked forked copy of jest with change with codebase that imported 'mongoose' and the tests ran without errors.