Npm test -t db-connection

got error in the test npm test -t db-connection please see the image attached

I got the same error on the same returned value of 45993. I think the database has changed since the course material was written.

yep same problem here. No errors on the import and not a slow connection… the import terminated successfully and showed the following result for the movies DB

@aamm1991, @Eric_56922, @ggilbert,

Thanks for the report! This is due to an update not going through on our end. The handout has been updated to include a new version of this test file that reflects the accurate number of documents, which you guys have.

Sorry for the inconvenience!

2 Likes

hey @nathan.leniz, I’m afraid I’m still facing the issue described here.
I’ve downloaded the handouts multiple times in past couple of minutes (thinking it has been updated in the meantime, to include the appropriate changes in the test files) but I’m still facing the same issue.

Can you please double check this?
Thanks!

Update :
I apologize, I forgot to mention that I was running:
npm test -t mongoclient
and not:
npm test -t db-connection
that was described in the OP.

Screenshots :
mongoclient test:

db-connection test:

I don’t think the testing files downloaded with the lesson actually match up with the testing files used to validate the ticket.

Case in point:

Shows that I do not pass the tests.

Running the validation on the ticket, however, yields:

This is annoying.

Edit: I also re-downloaded all the course material. The “new” testing files have the same time stamp as the “old” testing files.

@Eric_56922 @ognjen

Thanks for the additional report. We’ll get this sorted out as quickly as possible!

Did anyone face this issue -
err

How soon will you be sorting this out. I download the latest version of the course file yesterday and my test are failing. Please see below:

Determining test suites to run…Setup Mongo Connection
FAIL test/db-connection.test.js (12.752s)
Connection
√ Can access MFlix data (273ms)
× Can retrieve a movie by id (285ms)
× Can retrieve first page of movies (987ms)

● Connection › Can retrieve a movie by id

TypeError: Cannot read property 'title' of null

  18 |     const id = "573a13a6f29313caabd17bd5"
  19 |     const movie = await MoviesDAO.getMovieByID(id)
> 20 |     expect(movie.title).toEqual("Once Upon a Time in Mexico")
     |                  ^
  21 |   })
  22 | 
  23 |   test("Can retrieve first page of movies", async () => {

  at title (test/db-connection.test.js:20:18)
  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 next] (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:28:13

● Connection › Can retrieve first page of movies

expect(received).toEqual(expected)

Expected value to equal:
  45993
Received:
  6000

  27 |     } = await MoviesDAO.getMovies()
  28 |     expect(firstPage.length).toEqual(20)
> 29 |     expect(numMovies).toEqual(45993)
     |                       ^
  30 |   })
  31 | })
  32 | 

  at toEqual (test/db-connection.test.js:29:23)
  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 next] (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:28:13

Test Suites: 1 failed, 1 total
Tests: 2 failed, 1 passed, 3 total
Snapshots: 0 total
Time: 25.993s
Ran all test suites matching /db-connection/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

Please assist asap since the course assignment deadline is very close.

This has already been sorted out. The numbers expected in your test output are correct.

I has this problem. I think it’s because project was written with Babel v6, but “npm install” installed Babel 7, where some packages were deprecated like preset-stage-1 or re-named (babel-preset-env => @babel/preset-env). So I think it is hard to edit for Babel 7, so we need downgrade babel in the project to exactly 6th version…

Running this command on Mac, I get the following error :-

server@1.0.0 test /Users/aj/projects/MongoDBUniv/mflix-js
jest --passWithNoTests “db-connection”

2019-02-18T15:14:16,271: [cli] Failed to open /Users/aj/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied

Watchman: watchman --no-pretty get-sockname returned with exit code=null, signal=SIGABRT, stderr= 2019-02-18T15:14:16,271: [cli] Failed to open /Users/aj/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied

Ignore my reply. I ran the following command and the tests complete with results

sudo chown -R $(whoami):staff ~/Library/LaunchAgents

Hi
I too received the same error while testing. It’s some kind of issue with latest versions of node.
I simply downgraded my version of node to 11.11.0 and it worked fine.
Thanks
Deepesh

I also got an error while testing, however validation code for Connection is correct.