bot-api/tests/memoryServer.ts

19 lines
395 B
TypeScript

import { MongoMemoryServer } from "mongodb-memory-server";
class MemoryServer {
mongod: MongoMemoryServer | undefined;
async start() {
this.mongod = await MongoMemoryServer.create();
const uri = this.mongod.getUri("bot");
process.env.MONGODB_URI = uri;
}
async stop() {
if (this.mongod) {
await this.mongod.stop();
}
}
}
export default new MemoryServer();