Test case for backend is failing
qriz1452 opened this issue · 0 comments
qriz1452 commented
Here is the console output for the failed testcase :
+ npm test
> server@1.0.0 test
> cross-env NODE_ENV=test jest --testTimeout=5000
FAIL tests/activity.test.js
GET /api/activities
✕ should get all the activities (4 ms)
● GET /api/activities › should get all the activities
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
8 | /* Connecting to the database before each test. */
9 | beforeEach(async () => {
> 10 | await mongoose.connect(process.env.MONGODB_URI);
| ^
11 | });
12 |
13 | /* Closing database connection after each test. */
at NativeConnection.Object.<anonymous>.Connection.openUri (node_modules/mongoose/lib/connection.js:689:11)
at node_modules/mongoose/lib/index.js:379:10
at node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
at promiseOrCallback (node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose.Object.<anonymous>.Mongoose._promiseOrCallback (node_modules/mongoose/lib/index.js:1224:10)
at Mongoose.Object.<anonymous>.Mongoose.connect (node_modules/mongoose/lib/index.js:378:20)
at Object.connect (tests/activity.test.js:10:18)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 1.492 s
Ran all test suites.