Migration test error

server@1.0.0 test C:\Users\Niwarthana\Downloads\mongodb\mflix-js
jest --passWithNoTests “migration”

Determining test suites to run…Setup Mongo Connection
FAIL test/migration.test.js
× migration (280ms)

● Migration › migration


Received: null

  12 |       lastupdated: {  $type: "date"  },
  13 |     })
> 14 |     expect(movie).not.toBeNull()
     |                       ^
  15 |   })
  16 | })
  17 |

  at toBeNull (test/migration.test.js:14:23)
  at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
  at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
  at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
  at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
  at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.777s, estimated 6s
Ran all test suites matching /migration/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

i need help

For those getting a “db not defined” error, I changed line 51 to use “await mflix.collection(“movies”)” not “db.movies”

Let me know if you are still facing issue.


i fixed it thank you