From e30ca1ddfdf81046f16de84bc2e7bec45178a06f Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 9 May 2023 16:23:29 +0100 Subject: [PATCH] add jest config to probe --- Probe/Jobs/Alive.ts | 4 +++- Probe/Jobs/Monitor.ts | 4 +++- Probe/jest.config.json | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 Probe/jest.config.json diff --git a/Probe/Jobs/Alive.ts b/Probe/Jobs/Alive.ts index a008e1c421..ba9fa34694 100644 --- a/Probe/Jobs/Alive.ts +++ b/Probe/Jobs/Alive.ts @@ -6,6 +6,7 @@ import LocalCache from 'CommonServer/Infrastructure/LocalCache'; import URL from 'Common/Types/API/URL'; import logger from 'CommonServer/Utils/Logger'; import ProbeAPIRequest from '../Utils/ProbeAPIRequest'; +import Register from '../Services/Register'; RunCron( 'Basic:Alive', @@ -15,7 +16,8 @@ RunCron( }, async () => { if (!LocalCache.getString('PROBE', 'PROBE_ID')) { - logger.warn('Probe is not registered yet. Skipping alive check.'); + logger.warn('Probe is not registered yet. Skipping alive check. Trying to register probe again...'); + await Register.registerProbe(); return; } diff --git a/Probe/Jobs/Monitor.ts b/Probe/Jobs/Monitor.ts index dd5d028e99..019bf60bf7 100644 --- a/Probe/Jobs/Monitor.ts +++ b/Probe/Jobs/Monitor.ts @@ -5,6 +5,7 @@ import { PROBE_API_URL, PROBE_KEY } from '../Config'; import LocalCache from 'CommonServer/Infrastructure/LocalCache'; import URL from 'Common/Types/API/URL'; import logger from 'CommonServer/Utils/Logger'; +import Register from '../Services/Register'; RunCron( 'Basic:Monitor', @@ -18,7 +19,8 @@ RunCron( // for each monitor, ping and then report back to probe-api if (!LocalCache.getString('PROBE', 'PROBE_ID')) { - logger.warn('Probe is not registered yet. Skipping alive check.'); + logger.warn('Probe is not registered yet. Skipping alive check. Trying to register probe again...'); + await Register.registerProbe(); return; } diff --git a/Probe/jest.config.json b/Probe/jest.config.json new file mode 100644 index 0000000000..03e2b0db21 --- /dev/null +++ b/Probe/jest.config.json @@ -0,0 +1,27 @@ +{ + "preset": "ts-jest", + "verbose": true, + "globals": { + "ts-jest": { + "tsconfig": "tsconfig.json", + "babelConfig": false + } + }, + "moduleFileExtensions": ["ts", "js", "json"], + "transform": { + ".(ts|tsx)": "ts-jest" + }, + "testEnvironment": "node", + "collectCoverage": true, + "coverageReporters": ["text"], + "testRegex": "./Tests/(.*).test.ts", + "collectCoverageFrom": ["./**/*.(tsx||ts)"], + "coverageThreshold": { + "global": { + "lines": 0, + "functions": 0, + "branches": 0, + "statements": 0 + } + } +}