Spaces:
Paused
Paused
File size: 830 Bytes
c904036 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* eslint-disable no-unused-vars */
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');
const mongoose = require('mongoose');
let app;
let mongoServer;
describe('API Integration Tests', () => {
beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
process.env.MONGO_URI = mongoUri;
app = require('../../app');
});
afterAll(async () => {
await mongoose.disconnect();
await mongoServer.stop();
});
beforeEach(async () => {
try {
const collections = mongoose.connection.collections;
for (const key in collections) {
await collections[key].deleteMany({});
}
} catch (error) {
console.log('Cleanup error (ignored):', error.message);
}
});
});
|