Github Actions - I keep getting this error even after several tries. Any suggestions please?

Here is the link to the Lab: Sign In | KodeKloud

I ran the unit test, but i’m being met with that error even after adding the necessary env repository variables such as MONGO_USERNAME, MONGO_PASSWORD and MONGO_URI from the MONGO DB atlas data base i created earlier today.

That appears to be the link to a lecture, and not a lab. Did you mean the “Lab - Create Workflow with Unit testing and Code Coverage”?

My Bad, Mr.Rob. I was following the Lecture and every step Barahalikar Siddharth created on mine locally not on the Lab environment and was met with that error. Hope this helps.

OK, I needed to review the course sufficiently to figure out how he deals with the MongoDB dependency. Regrettably, he punts on it; he really should tell you how to get set up, but he does not, and that’s a huge problem for the course.

To deal with this issue, you first need to get the app working locally. Make sure that your atlas DB works in the app on your laptop. My mongo admin skills are rusty, to the extent I was ever good at it, which I probably was not. But if your app won’t work locally with your atlas credentials, they won’t work in Github Action either so that is your first job. The code appears to be correct for a Mongo account although TBH I still don’t have my Macintosh based server working yet.

We have very limited access to the course creator, but this is an area where we need to modify the course to make it reasonable for students. I’ll see who I can talk to, but cannot make any promises on when such a thing might happen.

To test running the app locally using VSCode, as he does in the course, you may want to create a .vscode/launch.json file. Mine looks like this, and works:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch App",
      "program": "${workspaceFolder}/app.js",
      "request": "launch",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "envFile": "${workspaceFolder}/.env",
      "type": "node"
    },
    {
      "type": "node",
      "request": "launch",
      "name": "mocha test",
      "envFile": "${workspaceFolder}/.env",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/app-test.js"
    }
  ]
}

The .env file sits at the root of the project (include “.env” in your .gitignore file) and has a format like this:

MONGO_USERNAME=atlas-user-account
MONGO_PASSWORD=some-fancy-password
MONGO_URI="mongodb+srv://some.subdomain.mongodb.net/?retryWrites=true&w=majority&appName=SomeCluster"

This will allow you to use the same code locally as on Github.

I have a dummy json file that will pass the tests if imported to the mongodb instance:

[{
	"_id": {
		"$oid": "667d9ba47103842ba9dc9988"
	},
	"id": 3,
	"name": "Earth",
	"description": "home",
	"image": "images/earth.png",
	"velocity": 29.8,
	"distance": 149.6
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc9989"
	},
	"id": 2,
	"name": "Venus",
	"description": "hot",
	"image": "images/venus.png",
	"velocity": 35,
	"distance": 108.2
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998a"
	},
	"id": 1,
	"name": "Mercury",
	"description": "small",
	"image": "images/mercury.png",
	"velocity": 47.4,
	"distance": 57.9
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998b"
	},
	"id": 4,
	"name": "Mars",
	"description": "red",
	"image": "images/mars.png",
	"velocity": 24.1,
	"distance": 228
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998c"
	},
	"id": 5,
	"name": "Jupiter",
	"description": "big",
	"image": "images/jupiter.png",
	"velocity": 13.1,
	"distance": 778.5
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998d"
	},
	"id": 6,
	"name": "Saturn",
	"description": "rings",
	"image": "images/saturn.png",
	"velocity": 9.7,
	"distance": 1432
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998e"
	},
	"id": 7,
	"name": "Uranus",
	"description": "joke",
	"image": "images/uranus.png",
	"velocity": 6.8,
	"distance": 2867
},
{
	"_id": {
		"$oid": "667d9ba47103842ba9dc998f"
	},
	"id": 8,
	"name": "Neptune",
	"description": "blue",
	"image": "images/neptune.png",
	"velocity": 5.4,
	"distance": 4515
}]