hagopj13 / node-express-boilerplate

A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
MIT License
7k stars 2.05k forks source link

Tests failing due to MongoWriteConcern #288

Closed WarutereD closed 9 months ago

WarutereD commented 9 months ago

Running yarn test on a boilerplate server results in

Test Suites: 3 failed, 4 passed, 7 total Tests: 89 failed, 24 passed, 113 total Snapshots: 0 total Time: 40.157 s, estimated 60 s Ran all test suites.

Found the issue to be due to changes in MongoDB Node.js Drivers Fix: in src/config/config.js Update mongoose connection code to mongoose: { url: envVars.MONGODB_URL + (envVars.NODE_ENV === 'test' ? '-test' : ''), options: { useCreateIndex: true, useNewUrlParser: true, useUnifiedTopology: true, writeConcern: { w: 'majority', }, }, },