GitHub Actions Course: Workflow – Configure Unit Testing chapter's workflow is failing

I am going through GitHub Actions course, and in , Configure Unit Testing chapter’s workflow I am trying to mimic the demonstration. Here is my workflow code so far:-

name: Solar System workflow

on:
  workflow_dispatch: 
  push:
    branches: 
        - main
        - 'feature/*'
 
env:
    MONGO_URI: 'mongodb+srv://supercluster.d83jj.mongodb.net/superdata'
    MONGO_USERNAME: ${{ vars.MONGO_USERNAME }}
    MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
jobs:
    unit-testing:
        strategy:
            matrix:
              os: [ubuntu-latest]
        name: Unit esting
        runs-on: ${{ matrix.os }}
        steps:
            - name: Checkout repository
              uses: actions/checkout@v4
            - name: Setup NodeJS Version -18
              uses: actions/setup-node@v3
              with:
                node-version: 18
            - name: Install Dependencies
              run: npm install
            - name: Unit Testing
              run: npm run test

However, Unit Testing step is failing every time. Here is the logs:-

When I ran npm run test && echo $? in my localhost it is also gave same error. What I am missing here?

Same problem

Sorry for the delay in a response on this issue – I’ve recently being going through the Github Actions course, and only recently became familiar enough with the course materials to answer questions about the course.

The problem here is that you need access to a MongoDB server with the right data, and the course does not make that directly available. You need to:

  1. Set up a mongo server; Atlas is one place you get do this.
  2. You need to have a copy of the database. I don’t have the original, but I made one that’s close enough to the real thing that it will pass the tests, which is why your jobs are failing.

I’ll see if we can’t add this material to the course, but for now, here’s a copy of the database:

[{
	"_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
}]

Hi Rob, sadly this didn’t work for me.

The instructor does not reveal the needed information until Lab 3, Step 6, but he does reveal it there: he’s set up a mongo repo with the needed info.

Because he buries the info pretty deep this way, you can’t really follow along in this part of the course. This is a discussion I’ve had with our lab engineering course, and while they’re going to fix this, they haven’t done so yet.

So do Lab 3, and use his mongo link to get the lab to work.