Npm run coverage fails

Hello.
I’m trying to follow the course GitHub Workflows but on the CI part when I’m trying to run de npm run coverage a receive this:

 npm run coverage

> Solar [email protected] coverage
> nyc --reporter cobertura --reporter lcov --reporter text --reporter json-summary  mocha app-test.js --timeout 10000  --exit

Server successfully running on port - 3000


  Planets API Suite
    Fetching Planet Details
      1) it should fetch a planet named Mercury
      2) it should fetch a planet named Venus
      3) it should fetch a planet named Earth
      4) it should fetch a planet named Mars
      5) it should fetch a planet named Jupiter
      6) it should fetch a planet named Satrun
      7) it should fetch a planet named Uranus
      8) it should fetch a planet named Neptune

  Testing Other Endpoints
    it should fetch OS Details
      ✔ it should fetch OS details
    it should fetch Live Status
      ✔ it checks Liveness endpoint
    it should fetch Ready Status
      ✔ it checks Readiness endpoint


  3 passing (792ms)
  8 failing

1) Planets API Suite
       Fetching Planet Details
         it should fetch a planet named Mercury:
     Uncaught AssertionError: expected {} to have property 'id'
      at /home/sergi/DevOpsProjects/cicd/githubactions/kodekloud-course/resources/solar-system/app-test.js:23:42
      at Request.callback (node_modules/superagent/lib/node/index.js:857:12)
      at IncomingMessage.<anonymous> (node_modules/superagent/lib/node/index.js:1070:18)
      at IncomingMessage.emit (node:events:529:35)
      at endReadableNT (node:internal/streams/readable:1400:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

The version of node is 18.20.0 and npm 10.8.2
The npm test runs ok without errors.
I create a database on mongo atlas with the database and import the planets db.


Thanks for advance

I’d guess you’re running npm test directly on you computer. If so, the credentials for the MongoDB database need to be in the environment before you run npm test, or the queries to the DB will fail. You can find the credentials in the Create Workflow with Unit testing and Code Coverage lab in Step 6 of the lab; note those carefully, since people tend to get the case of the password wrong.

Hello rob.
Thanks for your response
I’m trying to reproduce the course steps with my own database.
I make a db in atlas and put the credentials in the app.js like in the video but with code of app I receive this errors. I think that is because the db has no data and I make a python script to upload the data planets on a solarsystem db with planets collection that you post on another post.
Maybe the is not the correct manner to follow the course and I have to see all the videos before. If you have anny suggestion.
Thanks

I’ve done that myself; it’s a lot of work, since the database needs to have a particular schema to actually work. Since this isn’t a MongoDB course, it makes sense not to do that unless you enjoy that.

Easiest to use an existing DB. More details you can find in this thread from last month.

Hello Rob
Thanks for the suggestions. After connect to the existing DB I can export the DB and import with the python script on my atlas mongodb. Now npm test, npm run coverage works well hardcoding the uri, user and passwd
Following the course well for now.
Thanks for all