Skip to content

Commit

Permalink
Remove the need for live MongoDB for test
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldkubota committed Jul 19, 2021
1 parent 53e1ead commit 6776d05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-import": "^2.22.1",
"mocha": "^8.2.1",
"mongodb-memory-server": "^7.2.1",
"nyc": "^15.1.0",
"sinon": "^9.2.3",
"supertest": "^6.0.1"
Expand Down
10 changes: 10 additions & 0 deletions test/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const request = require('supertest');

const { MongoMemoryServer } = require('mongodb-memory-server');

(async () => {
const mongoServer = await MongoMemoryServer.create();
const mockMongoDBUri = await mongoServer.getUri();
process.env.MONGODB_URI=mockMongoDBUri;

const app = require('../app.js');

describe('GET /', () => {
Expand Down Expand Up @@ -104,3 +112,5 @@ describe('GET /random-url', () => {
.expect(404, done);
});
});

})();

0 comments on commit 6776d05

Please sign in to comment.