Skip to content

Commit

Permalink
Remove mongodb memory server
Browse files Browse the repository at this point in the history
  • Loading branch information
hagopj13 committed Nov 10, 2019
1 parent e559c13 commit 45ad16f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 339 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORT=3000
MONGODB_URL=mongodb://localhost:27017/node-boilerplate
MONGODB_URL=mongodb://127.0.0.1:27017/node-boilerplate
JWT_SECRET=thisisasamplesecret
JWT_ACCESS_EXPIRATION_MINUTES=30
JWT_REFRESH_EXPIRATION_DAYS=30
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- '12'
services:
- mongodb
cache: yarn
branches:
only:
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"mongodb-memory-server": "^6.0.1",
"node-mocks-http": "^1.8.0",
"nodemon": "^1.19.4",
"prettier": "^1.18.2",
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
env: envVars.NODE_ENV,
port: envVars.PORT,
mongoose: {
url: envVars.MONGODB_URL,
url: envVars.MONGODB_URL + (envVarsSchema.NODE_ENV === 'test' ? '-test' : ''),
options: { useCreateIndex: true, useNewUrlParser: true, useUnifiedTopology: true },
},
jwt: {
Expand Down
8 changes: 1 addition & 7 deletions tests/utils/setupTestDB.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const mongoose = require('mongoose');
const { MongoMemoryServer } = require('mongodb-memory-server');
const config = require('../../src/config/config');

let mongod;

const setupTestDB = () => {
beforeAll(async () => {
mongod = new MongoMemoryServer();
const uri = await mongod.getUri();
await mongoose.connect(uri, config.mongoose.options);
await mongoose.connect(config.mongoose.url, config.mongoose.options);
});

beforeEach(async () => {
Expand All @@ -17,7 +12,6 @@ const setupTestDB = () => {

afterAll(async () => {
await mongoose.disconnect();
await mongod.stop();
});
};

Expand Down
Loading

0 comments on commit 45ad16f

Please sign in to comment.