Comment insertion not working correctly [Solved]

I’m trying to do the [Create/Update Comments] Ticket.

The insert unitest keeps failing on this line: expect(martianComments[0]._id).toEqual(postCommentResult.insertedId)

With both expected_val (ie: martianComments[0]._id) and actual_val (ie: postCommentResult.insertedId) having values, but they don’t match.

When I look up the comment _id that matches the expected_val, I can see it’s the pre-inserted comment with the latest date - date is “2018-08-13 20:35:16.068”, text is “nope”. I also notice that the movie_id field looks like this ->
movie_id: ObjectId(<movie_id_value>)

I can find my inserted comment, but I notice that the movie_id field looks like this ->
movie_id: <movie_id_value>

Skimming the video again, I can’t find pointers on how to fix this. What could I be doing wrong?

Okay, did an educated guess and submitted
“movie_id”: ObjectId(movieId)
when inserting instead of
“movie_id”: movieId

And now it’s passing the unit tests. Still not sure if that’s the right way to do it though, or how I was supposed to figure that out without spelunking.

1 Like

Hi @Erica_Stevenson_73099

We do expect a little spelunking as part of the lab sessions, but if there is anything unclear or where you think we could improve the language to better sign post the session, please let us know as we would appreciate the feedback to improve the course going forward.

Kindest regards,