chai icon indicating copy to clipboard operation
chai copied to clipboard

Mongoose v6 ObjectId deepEqual always true

Open spaiz opened this issue 2 years ago • 2 comments

Hi. We did pay attention in our tests that we cannot rely anymore on deep.equal when comparing objects with ObjectId() or even ObjectIds itself.

Env: node v16 Mongoose version: v5 vs v6

For the mongoose v5 tests work as expected.

{
  "dependencies": {
    "chai": "^4.3.6",
    "mocha": "^10.0.0",
    "mongoose": "^5.0.0"
  }
}
Screen Shot 2022-06-13 at 13 42 38

For mongoose v6 tests are passing when they should fail.

{
  "dependencies": {
    "chai": "^4.3.6",
    "mocha": "^10.0.0",
    "mongoose": "^6.0.0"
  }
}
Screen Shot 2022-06-13 at 13 41 55

I did prepare a repo for reproducing the issue: https://github.com/spaiz/objectId_tests

spaiz avatar Jun 13 '22 10:06 spaiz

I assume this PR should fix it :/

https://github.com/chaijs/deep-eql/pull/86

spaiz avatar Jun 21 '22 07:06 spaiz

hi any news on this?

leyb-guesty avatar May 08 '23 08:05 leyb-guesty