From 4c9247d98de1d849ca5bf2bf6c7e4dfb34c85d4f Mon Sep 17 00:00:00 2001 From: aelassas Date: Mon, 18 Nov 2024 15:23:50 +0100 Subject: [PATCH] Update testHelper.ts --- api/package.json | 2 +- api/tests/testHelper.ts | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/api/package.json b/api/package.json index 404f5a81f..57219fc2a 100644 --- a/api/package.json +++ b/api/package.json @@ -8,7 +8,7 @@ "dev": "nodemon", "build": "rimraf dist && cross-env NODE_OPTIONS=--max-old-space-size=1024 tsc --build --verbose && babel dist -d dist", "start": "npm run build && node dist/src", - "test": "rimraf coverage && npm run build && cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --no-cache", + "test": "rimraf coverage && npm run build && cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --no-cache --runInBand", "lint": "eslint --ext .ts .", "ncu": "ncu -u -x typescript,eslint,@types/express", "db:script": "npm run build && node dist/scripts/db.js" diff --git a/api/tests/testHelper.ts b/api/tests/testHelper.ts index 4a13c86fb..798f2ea11 100644 --- a/api/tests/testHelper.ts +++ b/api/tests/testHelper.ts @@ -59,25 +59,17 @@ export const initialize = async () => { // env admin if (env.ADMIN_EMAIL) { - let adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL, type: bookcarsTypes.UserType.Admin }) + const adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL }) if (!adminFromEnv) { - // - // This check is necessary to avoid getting an error creating the same env admin multiple times when - // test suites are run in parallel. - // - await delay(1000) - adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL }) - if (!adminFromEnv) { - const _admin = new User({ - fullName: 'admin', - email: env.ADMIN_EMAIL, - language: LANGUAGE, - password: passwordHash, - type: bookcarsTypes.UserType.Admin, - }) - await _admin.save() - expect(_admin.id).toBeTruthy() - } + const _admin = new User({ + fullName: 'admin', + email: env.ADMIN_EMAIL, + language: LANGUAGE, + password: passwordHash, + type: bookcarsTypes.UserType.Admin, + }) + await _admin.save() + expect(_admin.id).toBeTruthy() } }