Course: Jenkins Pipelines
The unit tests for this project are failing. In order for the pipeline to continue executing, I am using the || true instruction at the end of the test command, preventing it from being interrupted.
Is there any recommendation or instruction to fix the unit tests that are failing?
My tests were:
1º
sudo docker run --rm -it -v “${PWD}:/app” -w/app node:16.20.2 bash
2º
npm install --no-audit
3º
export MONGO_URI=“mongodb+srv://supercluster.d83jj.mongodb.net/SuperData” &&
export MONGO_USERNAME=“superuser” &&
export MONGO_PASSWORD=“************”
4º
npm test
Output:
Is there some reason you can’t run npm test directly on your laptop? Running it under docker is likely an additional level of complexity. There dragons lie 
I turned off the junit reporter to get the clearest feedback using the standard reporter (it’s specified in package.json). I did the following:
$ export MONGO_USERNAME=superuser
$ export MONGO_URI="mongodb+srv://supercluster.d83jj.mongodb.net/superData"
$ export MONGO_PASSWORD=****
$ npm test
> Solar [email protected] test
> mocha app-test.js --timeout 10000 --exit
Server successfully running on port - 3000
Planets API Suite
Fetching Planet Details
(node:7201) [DEP0170] DeprecationWarning: The URL mongodb://supercluster-shard-00-02.d83jj.mongodb.net:27017,supercluster-shard-00-00.d83jj.mongodb.net:27017,supercluster-shard-00-01.d83jj.mongodb.net:27017/superData?authSource=admin&replicaSet=atlas-11b0vt-shard-0&ssl=true is invalid. Future versions of Node.js will throw an error.
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ it should fetch a planet named Mercury (1057ms)
✔ it should fetch a planet named Venus (88ms)
✔ it should fetch a planet named Earth (87ms)
✔ it should fetch a planet named Mars (86ms)
✔ it should fetch a planet named Jupiter (86ms)
✔ it should fetch a planet named Satrun (85ms)
✔ it should fetch a planet named Uranus (125ms)
✔ it should fetch a planet named Neptune (104ms)
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
11 passing (2s)
Try this in a virtual, or try this on your system using a bash shell. Should work, as it does for me.
Now it’s working as expected. The problem was at the end of the MONGO_URI variable, where I had written “superData” with a lowercase “d” (“superdata”), causing the error.