X Database handle created from MongoClient Collection handle created from database handle (61ms)

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\Admin>cd C:\mflix-js

C:\mflix-js>npm test -t mongoclient

server@1.0.0 test C:\mflix-js
jest --passWithNoTests “mongoclient”

Determining test suites to run…Setup Mongo Connection
(node:6064) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new
Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:6064) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new
Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
FAIL test/lessons/mongoclient.spec.js
MongoClient
√ Client initialized with URI (66ms)
√ Client initialized with URI and options (44ms)
x Database handle created from MongoClient (55ms)
x Collection handle created from database handle (43ms)

? MongoClient > Database handle created from MongoClient

TypeError: Cannot read property 'close' of undefined

  105 |       expect(e).toBeNull()
  106 |     } finally {
> 107 |       testClient.close()
      |                  ^
  108 |     }
  109 |   })
  110 |

  at close (test/lessons/mongoclient.spec.js:107:18)
  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.<computed> [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)

? MongoClient > Collection handle created from database handle

TypeError: Cannot read property 'close' of undefined

  137 |       expect(e).toBeNull()
  138 |     } finally {
> 139 |       testClient.close()
      |                  ^
  140 |     }
  141 |   })
  142 | })

  at close (test/lessons/mongoclient.spec.js:139:18)
  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.<computed> [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: 2 failed, 2 passed, 4 total
Snapshots: 0 total
Time: 4.989s
Ran all test suites matching /mongoclient/i.
Teardown Mongo Connection
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to trou
bleshoot this issue.

Hi @Shrawan_70379,

Please follow the setup steps again. Seems like something is missing.

  • Check that configuration file is renamed to .env
  • URI is correct in .env file

Also, you are trying to run lesson test, start by connection test :slight_smile: and lets see how application is running.

Kanika