Havin simillar issue:
$ npm test -t mongoclient
server@1.0.0 test /Users/pavitenterprises/Documents/M220JS/mflix-js 2
jest --passWithNoTests “mongoclient”
Determining test suites to run…Setup Mongo Connection
FAIL test/lessons/mongoclient.spec.js (7.637s)
MongoClient
✓ Client initialized with URI (1899ms)
✕ Client initialized with URI and options (572ms)
✓ Database handle created from MongoClient (2055ms)
✕ Collection handle created from database handle (689ms)
● MongoClient › Client initialized with URI and options
TypeError: Cannot read property 'close' of undefined
65 | expect(e).toBeNull();
66 | } finally {
> 67 | testClient.close();
| ^
68 | }
69 | });
70 |
at close (test/lessons/mongoclient.spec.js:67:15)
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 throw] (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:30:13
● MongoClient › Collection handle created from database handle
TypeError: Cannot read property 'close' of undefined
128 | expect(e).toBeNull();
129 | } finally {
> 130 | testClient.close();
| ^
131 | }
132 | });
133 | });
at close (test/lessons/mongoclient.spec.js:130:15)
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 throw] (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:30:13
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 passed, 4 total
Snapshots: 0 total
Time: 7.815s, estimated 8s
Ran all test suites matching /mongoclient/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.