/* eslint-disable no-restricted-syntax */
/* eslint-disable no-await-in-loop */
import mongoose from 'mongoose';
import nock from 'nock';

beforeAll(async () => {
  await mongoose.connect(process.env.MONGO_URL!);
});

beforeEach(async () => {
  jest.clearAllMocks();
  nock.cleanAll();

  const collections = await mongoose.connection.db.collections();
  for (const coll of collections) {
    await coll.deleteMany({});
  }
});

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