From 6134a7d35e77fba4ccdcccb1ad14fdb0f78d4a66 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 12 Mar 2023 11:33:02 +0100 Subject: [PATCH] Moving config during testing to tests asset folder #587 --- package-lock.json | 14 +++++++------- package.json | 2 +- src/common/config/private/Config.ts | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42fabb78..056f1fb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "sharp": "0.31.3", "ts-exif-parser": "0.2.2", "ts-node-iptc": "1.0.11", - "typeconfig": "2.0.38", + "typeconfig": "2.0.39", "typeorm": "0.3.12", "xml2js": "0.4.23" }, @@ -21670,9 +21670,9 @@ } }, "node_modules/typeconfig": { - "version": "2.0.38", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.38.tgz", - "integrity": "sha512-yN9rRqJQ21xAYdR/1vhv4DPurOA7DNCN7zqPDPD6ZA2fLKcNTRa2flG/z2FaQE4UuBfnQ1o96c50xeNozDMbZQ==", + "version": "2.0.39", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.39.tgz", + "integrity": "sha512-Wys54XBKXeUSfaqrPajTCi6lY3c1b/M/PotGWVL5KT6393IO317wq45F/5otFBuFVREIh+4gRG6c/y+SvSZXYw==", "dependencies": { "minimist": "1.2.8" } @@ -39736,9 +39736,9 @@ } }, "typeconfig": { - "version": "2.0.38", - "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.38.tgz", - "integrity": "sha512-yN9rRqJQ21xAYdR/1vhv4DPurOA7DNCN7zqPDPD6ZA2fLKcNTRa2flG/z2FaQE4UuBfnQ1o96c50xeNozDMbZQ==", + "version": "2.0.39", + "resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.0.39.tgz", + "integrity": "sha512-Wys54XBKXeUSfaqrPajTCi6lY3c1b/M/PotGWVL5KT6393IO317wq45F/5otFBuFVREIh+4gRG6c/y+SvSZXYw==", "requires": { "minimist": "1.2.8" } diff --git a/package.json b/package.json index c5051ca2..aee296a9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "sharp": "0.31.3", "ts-exif-parser": "0.2.2", "ts-node-iptc": "1.0.11", - "typeconfig": "2.0.38", + "typeconfig": "2.0.39", "xml2js": "0.4.23", "typeorm": "0.3.12" }, diff --git a/src/common/config/private/Config.ts b/src/common/config/private/Config.ts index cb189ac5..bf517148 100644 --- a/src/common/config/private/Config.ts +++ b/src/common/config/private/Config.ts @@ -10,9 +10,13 @@ import {TAGS} from '../public/ClientConfig'; declare const process: any; const upTime = new Date().toISOString(); +// TODO: Refactor Config to be injectable globally. +// This is a bad habit to let the Config know if its in a testing env. +const isTesting = ['afterEach', 'after', 'beforeEach', 'before', 'describe', 'it'] + .every((fn) => (global as any)[fn] instanceof Function); @ConfigClass & ServerConfig>({ - configPath: path.join(__dirname, './../../../../config.json'), + configPath: path.join(__dirname, !isTesting ? './../../../../config.json' : './../../../../test/backend/assets/config.json'), saveIfNotExist: true, attachDescription: true, enumsAsString: true,