Good night! Mine is Wilson Palmeira, I am enrolled in the Course M220JS.
When I run npm test -t projection, it fails, below is the error message. How to fix it?
C:\mflix-js>npm test -t projection
server@1.0.0 test C:\mflix-js
jest --passWithNoTests “projection”
Determining test suites to run…Setup Mongo Connection
(node:5588) 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 MongoClient.connect.
(node:5588) UnhandledPromiseRejectionWarning: Error: Caught error after test environment was torn down
expect(received).toEqual(expected) // deep equality
Expected: 1468
Received: 0
(node:5588) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5588) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
FAIL test/projection.test.js (46.03s)
Projection
× Can perform a country search for one country (447ms)
× Can perform a country search for three countries (5008ms)
● Projection › Can perform a country search for one country
expect(received).toEqual(expected) // deep equality
Expected: 2
Received: 0
9 | const kosovoList = ["Kosovo"]
10 | const movies = await MoviesDAO.getMoviesByCountry(kosovoList)
> 11 | expect(movies.length).toEqual(2)
| ^
12 | })
13 |
14 | test("Can perform a country search for three countries", async () => {
at toEqual (test/projection.test.js:11:27)
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)
● Projection › Can perform a country search for three countries
: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:
12 | })
13 |
> 14 | test("Can perform a country search for three countries", async () => {
| ^
15 | const countriesList = ["Russia", "Japan", "Mexico"]
16 | const movies = await MoviesDAO.getMoviesByCountry(countriesList)
17 | expect(movies.length).toEqual(1468)
at new Spec (node_modules/@jest/core/node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
at Suite.test (test/projection.test.js:14:3)
Test Suites: 1 failed, 1 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: 71.281s
Ran all test suites matching /projection/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 troubleshoot this issue.
events.js:292
throw er; // Unhandled ‘error’ event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
Emitted ‘error’ event on Connection instance at:
at TLSSocket. (C:\mflix-js\node_modules\mongodb\lib\core\connection\connection.js:321:10)
at Object.onceWrapper (events.js:422:26)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
name: ‘MongoNetworkError’,
errorLabels: [ ‘TransientTransactionError’ ],
[Symbol(mongoErrorContextSymbol)]: {}
}
npm ERR! Test failed. See above for more details.
C:\mflix-js>
C:\mflix-js>npm test -t db-connection
server@1.0.0 test C:\mflix-js
jest --passWithNoTests “db-connection”
Determining test suites to run…Setup Mongo Connection
(node:6288) 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 MongoClient.connect.
FAIL test/db-connection.test.js
● Test suite failed to run
TypeError: Cannot read property 'close' of undefined
17 |
18 | async teardown() {
> 19 | await this.global.mflixClient.close()
| ^
20 | await super.teardown()
21 | }
22 |
at MongoEnvironment.teardown (test/config/mongoEnvironment.js:19:35)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 130.293s
Ran all test suites matching /db-connection/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.