Removed mongodb-memory-server
Unit Tests with docker compose / unit-test (pull_request) Has been cancelled Details

This commit is contained in:
Sugui 2023-12-31 11:42:19 +01:00
parent e1ced40c06
commit ec1b693538
3 changed files with 2 additions and 29 deletions

View File

@ -3,14 +3,13 @@
"module": "index.ts",
"type": "module",
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/supertest": "^6.0.1",
"@types/express": "^4.17.21",
"@types/express-list-endpoints": "^6.0.3",
"@types/jest": "^29.5.11",
"@types/jsonwebtoken": "^9.0.5",
"@types/supertest": "^6.0.1",
"bun-types": "latest",
"jest": "^29.7.0",
"mongodb-memory-server": "^9.1.3",
"supertest": "^6.3.3",
"ts-jest": "^29.1.1"
},

View File

@ -1,5 +1,4 @@
import {
afterAll,
afterEach,
beforeAll,
describe,
@ -10,7 +9,6 @@ import {
import request, { Response } from "supertest";
import app, { startApp } from "../src/app";
import imageService from "../src/services/ImageService";
import memoryServer from "./memoryServer";
import populateDatabase from "./populateDatabase";
const imageServiceOriginal = imageService;
@ -18,7 +16,6 @@ const imageServiceOriginal = imageService;
let token: string;
beforeAll(async () => {
//if (!process.env.DEDICATED_MONGODB_SERVER) await memoryServer.start();
await startApp();
await populateDatabase();
@ -28,10 +25,6 @@ beforeAll(async () => {
token = tok.body.token;
});
/* afterAll(async () => {
if (!process.env.DEDICATED_MONGODB_SERVER) await memoryServer.stop();
});
*/
afterEach(() => {
mock.restore();
mock.module("../src/services/ImageService", () => ({

View File

@ -1,19 +0,0 @@
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();