add jest config to probe

This commit is contained in:
Simon Larsen 2023-05-09 16:23:29 +01:00
parent 4320be66f1
commit e30ca1ddfd
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
3 changed files with 33 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}

27
Probe/jest.config.json Normal file
View File

@ -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
}
}
}