Ticket: Create/Update Comments, 3rd test failed / Solved

Determining test suites to run…Setup Mongo Connection
console.error src/dao/commentsDAO.js:79
Unable to update comment: MongoError: E11000 duplicate key error collection: 5d0a0886014b767ead317d5e_sample_mflix.comments index: id dup key: { : ObjectId(‘5d6e694e9dc4b51b346e78e0’) }

    √ Can post a comment (201ms)
    √ Can update a comment (187ms)
    × Can only update comment if user posted comment (145ms)

  ● Create/Update Comments › Can only update comment if user posted comment

    expect(received).toBe(expected) // Object.is equality

    Expected: 0
    Received: undefined

    Difference:

      Comparing two different types of values. Expected number but received undefined.

      83 |     )
      84 | 
    > 85 |     expect(updateCommentResult.modifiedCount).toBe(0)
         |                                               ^
      86 |     console.log(updateCommentResult)
      87 |   })
      88 | })

      at toBe (test/create-update-comments.test.js:85:47)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

Test Suites: 1 failed, 1 total
Tests:       1 failed, 2 passed, 3 total
Snapshots:   0 total
Time:        3.436s
Ran all test suites matching /create-update-comments/i.
Teardown Mongo Connection
npm ERR! Test failed.  See above for more details.

First and second test pass, but third does not.
Any suggestions ?

Please check your messages.

Kanika

Found error,
I did put { upsert: true} in comments update method, which was mistake.

1 Like