Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions backend/jest-mongodb-config.js

This file was deleted.

2 changes: 1 addition & 1 deletion backend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
preset: '@shelf/jest-mongodb',
testEnvironment: 'node',
setupFilesAfterEnv: ['./jest.setup.js'],
watchPathIgnorePatterns: ['globalConfig'],
testPathIgnorePatterns: ['/test/old-tests/'],
Expand Down
1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@babel/core": "^7.15.0",
"@babel/eslint-parser": "^7.15.0",
"@babel/eslint-plugin": "^7.14.5",
"@shelf/jest-mongodb": "^1.2.3",
"concurrently": "^5.1.0",
"debug": "^4.3.1",
"eslint": "^7.9.0",
Expand Down
25 changes: 25 additions & 0 deletions backend/setup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ module.exports = {
await removeAllCollections();
});

// Disconnect Mongoose
afterAll(async () => {
await dropAllCollections();
await mongoose.connection.close();
await mongoServer.stop();
});
},
setupIntegrationDB(databaseName) {
// Connect to Mongoose
beforeAll(async () => {
mongoServer = new MongoMemoryServer({
instance: { dbName: databaseName },
});
const mongoUri = await mongoServer.getUri();
const opts = {
useNewUrlParser: true,
useFindAndModify: false,
useCreateIndex: true,
useUnifiedTopology: true,
};
await mongoose.connect(mongoUri, opts, (err) => {
if (err) console.error(err);
});
});

// Disconnect Mongoose
afterAll(async () => {
await dropAllCollections();
Expand Down
Loading