Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.96k stars 3.84k forks source link

TypeError: Cannot read property 'Decimal128' of null #10803

Closed 4ty711 closed 2 years ago

4ty711 commented 3 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior?

I am getting: TypeError: Cannot read property 'Decimal128' of null

If the current behavior is a bug, please provide the steps to reproduce.

Install the latest version of mongoose and use the ObjectID Constructor.

What is the expected behavior?

In older versions, the path is correct.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

IslandRhythms commented 3 years ago

https://mongoosejs.com/docs/migrating_to_6.html

Mongoose 6 has several backwards breaking changes. Check if one of them is in your project, if not then provide a reproduction script because this issue does not have enough information to create one.

cbratschi commented 3 years ago

I have the same issue on Mongoose 5 after updating to 5.13.12.

vkarpov15 commented 3 years ago

@cbratschi can you please provide a script that demonstrates this issue?

amatiasq commented 2 years ago

Related to https://github.com/Automattic/mongoose/issues/7866

amatiasq commented 2 years ago

This happens to me when using jest.mock on multiple modules that end up depending on mongoose. Sorry I don't have time to provide a repo.

vkarpov15 commented 2 years ago

@amatiasq we strongly recommend using any testing framework other than Jest. Without a repro, there's no way for us to provide any advice other than to:

  1. Strongly consider using a different testing framework
  2. Read our jest testing docs and make sure you've followed the instructions