diff --git a/backend/app.js b/backend/app.js index 1f391612..5a373a87 100644 --- a/backend/app.js +++ b/backend/app.js @@ -195,11 +195,16 @@ if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') { mongoose.set('strictQuery', false) mongoose.connect(MONGODB_URI) } else { - var mongoDB = 'mongodb://localhost:27017/test' + const mongoDB = 'mongodb://localhost:27017/test' mongoose.set('strictQuery', false) mongoose.connect(mongoDB) - var db = mongoose.connection - db.on('error', logger.error('MongoDB connection error:')) + mongoose.connection.on('error', error => { + if (error.message.code === 'ETIMEDOUT') { + logger.error(error) + mongoose.connect(mongoDB) + } + logger.error(error) + }) } app.use(cors()) diff --git a/backend/package.json b/backend/package.json index 8da692d2..06ed8c92 100644 --- a/backend/package.json +++ b/backend/package.json @@ -7,7 +7,7 @@ "start": "NODE_ENV=production node index.js", "dev": "cross-env NODE_ENV=development nodemon index.js", "test": "NODE_ENV=test node --test --test-force-exit", - "test-githubactions": "cross-env NODE_ENV=testserver node --test **/*.test.js", + "test-githubactions": "cross-env NODE_ENV=testserver node --test --test-force-exit", "build:ui": "rm -rf build && cd ../frontend && npm run build --prod && cp -r build ../backend", "lint": "eslint .", "prettier": "prettier", @@ -47,7 +47,7 @@ }, "config": { "mongodbMemoryServer": { - "version": "4.2.8" + "version": "4.4.0" } } } diff --git a/backend/tests/game_testing.test.js b/backend/tests/game_testing.test.js index d1b9bc4c..2596f008 100644 --- a/backend/tests/game_testing.test.js +++ b/backend/tests/game_testing.test.js @@ -395,7 +395,6 @@ describe('it is possible to do tests', () => { const testCaseAdded = await caseToAdd.save() const data = [testMap['test0']] - console.log(addedTests, data) let res = await api .post(`/api/game/${testCaseAdded.id}/checkTests`) .set('Authorization', `bearer ${user.body.token}`)