Chapter 1 connection tests ticket failing

In chapter 1 when running npm test -t mongoclient I get 2 tests passing and 2 tests failing.
The errors shown in the shell were:

● MongoClient › Client initialized with URI and options

  • TypeError: Cannot read property ‘close’ of undefined*

  •  67 |       expect(e).toBeNull()*
    
  •  68 |     } finally {*
    
  • 69 | testClient.close()*

  •     |                  ^*
    
  •  70 |     }*
    
  •  71 |   })*
    
  •  72 | *
    
  •  at close (test/lessons/mongoclient.spec.js:69: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 throw] (node_modules/regenerator-runtime/runtime.js:97:21)*
    
  •  at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)*
    
  •  at _throw (node_modules/@babel/runtime/helpers/asyncToGenerator.js:29: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 | })*
    

I can access the mflix collection through the shell and Compass, and can run in localhost:5000. The secret key has been changed in the .env file, and I have looked at answers here in the forum but they did not work for me.
Thanks - Wayne.

Please try running npm test -t db-connection this command from mflix-js directory.

Also, make sure you have renamed the config file to .env and if still not resolved, please share the contents of .env file.

Kanika

Thanks for your time Kanika. I tried npm test -t db-connection and it worked fine - did the first submit ok. Still wondering why npm test -t mongoclient failed though.

Wayne

Not sure, it should have passed. Can you share the contents of .env file, so that I can take a look?

Kanika

my .env file:

SECRET_KEY=lbebbc78yyrbfHVKU6vjhvT8TvJvJjjMac
MFLIX_DB_URI=mongodb+srv://m220student:m220password@mflix-vahan.mongodb.net/test?retryWrites=true&w=majority
MFLIX_NS=sample_mflix
PORT=5000

I just made up a secret key - should it be anywhere else?
Thanks,

Wayne

No, that is fine. I am not able to connect to your cluster, if you can give me access (by clicking on access from anywhere), I may be able to test.