Some unit tests are not correct for the mongodb driver speficied for this course

I’m using mongodb for js driver 3.1.6 and I can’t pass the unit test user-management.test.js.

It seems the db.collection.insertOne(doc) will add a new _id field to doc. So the following in test file won’t hold any more.

delete user["_id"]
expect(user).toEqual(testUser)

You should do something like this to get around this:

delete user["_id"]
delete testUser["_id"]
expect(user).toEqual(testUser)

In fact, there are some other unit tests I can’t pass, but I can pass the tickets.

Hi @xue_22767,

I am able to pass the unit tests.

Yes, that is correct, whenever we are inserting a new document _id field will be added. So, that is why we are deleting the _id key from user doc (newly created document) before comparing them.
But it will not change the object testUser, you can try printing testUser, before running the following check.

Kanika