Solved: TypeError: Cannot read property 'close' of undefined

i am able to connect with

mongo "mongodb+srv://indra26:<mypassword>@mflix-ump1m.mongodb.net/test?retryWrites=true&w=majority"

I have edited dotenv.win

MFLIX_DB_URI=mongodb+srv://indra26:<mypassword>@mflix-ump1m.mongodb.net/test?retryWrites=true&w=majority

Getting this error.

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

> server@1.0.0 test D:\mflix-js
> jest --passWithNoTests "mongoclient"

Determining test suites to run...Setup Mongo Connection
 FAIL  test/lessons/mongoclient.spec.js
  ● Test suite failed to run

    TypeError: Cannot read property 'close' of undefined

      20 |
      21 |   async teardown() {
    > 22 |     await this.global.mflixClient.close()
         |                                   ^
      23 |     await super.teardown()
      24 |   }
      25 |

      at MongoEnvironment.teardown (test/config/mongoEnvironment.js:22:35)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.521s
Ran all test suites matching /mongoclient/i.
Teardown Mongo Connection
npm ERR! Test failed.  See above for more details.
You will have to edit dotenv.win to .env and you are good to go

I believe you have found the solution. :slight_smile: Let me know if you have further queries.

Kanika