Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update test cases #548

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,23 @@ DA:8,3
DA:14,5
DA:15,5
DA:16,5
DA:23,5
DA:31,5
DA:32,1
DA:34,5
DA:22,5
DA:29,5
DA:30,1
DA:32,5
DA:33,5
DA:35,5
DA:37,5
DA:40,3
DA:38,3
LF:15
LH:15
BRDA:14,0,0,5
BRDA:15,1,0,5
BRDA:15,1,1,1
BRDA:25,2,0,5
BRDA:25,2,1,4
BRDA:31,3,0,1
BRDA:31,4,0,5
BRDA:31,4,1,5
BRDA:24,2,0,5
BRDA:24,2,1,4
BRDA:29,3,0,1
BRDA:29,4,0,5
BRDA:29,4,1,5
BRF:8
BRH:8
end_of_record
6 changes: 2 additions & 4 deletions src/middleware/error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as util from 'util';
import * as express from 'express';
import { StatusCodes } from 'http-status-codes';
import ApiError from '../abstractions/ApiError';
import ApiError, { IError } from '../abstractions/ApiError';
import Crypto from '../lib/crypto';
import logger from '../lib/logger';

Expand All @@ -19,13 +19,11 @@ const addErrorHandler = (
\nREQUEST PARAMS:\n${util.inspect(req.params)}
\nREQUEST QUERY:\n${util.inspect(req.query)}
\nBODY:\n${util.inspect(req.body)}`);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let body: any = {
let body: IError | string = {
fields: err.fields,
message: err.message || 'An error occurred during the request.',
name: err.name,
status,
stack: '',
};

if (process.env.APPLY_ENCRYPTION && process.env.SECRET_KEY) {
Expand Down
54 changes: 27 additions & 27 deletions test-report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/dummy.spec.ts">
<testCase name="Dummy Test Cases Verify Jest is working" duration="2"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/lib/logger.spec.ts">
<testCase name="Logger Lib should create a new log directory if one doesn&apos;t already exist" duration="5"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/lib/crypto.spec.ts">
<testCase name="Crypto Lib (Encryption/Decryption) Testing for text" duration="7"/>
<testCase name="Crypto Lib (Encryption/Decryption) Testing for array" duration="2"/>
<testCase name="Crypto Lib (Encryption/Decryption) Testing for object" duration="2"/>
<testCase name="Crypto Lib (Encryption/Decryption) Testing for text" duration="4"/>
<testCase name="Crypto Lib (Encryption/Decryption) Testing for array" duration="3"/>
<testCase name="Crypto Lib (Encryption/Decryption) Testing for object" duration="1"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/lib/logger.spec.ts">
<testCase name="Logger Lib should create a new log directory if one doesn&apos;t already exist" duration="8"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/components/SystemStatusController.spec.ts">
<testCase name="System Status Controller test getError method" duration="2"/>
<testCase name="System Status Controller test getSystemInfo method" duration="3"/>
<testCase name="System Status Controller test getSystemInfo method with updated env variables" duration="4"/>
<testCase name="System Status Controller test getSystemInfo method with exception" duration="0"/>
<testCase name="System Status Controller test getServerTime method" duration="2"/>
<testCase name="System Status Controller test getServerTime method with exception" duration="1"/>
<testCase name="System Status Controller test getResourceUsage method" duration="0"/>
<testCase name="System Status Controller test getError method" duration="3"/>
<testCase name="System Status Controller test getSystemInfo method" duration="2"/>
<testCase name="System Status Controller test getSystemInfo method with updated env variables" duration="2"/>
<testCase name="System Status Controller test getSystemInfo method with exception" duration="1"/>
<testCase name="System Status Controller test getServerTime method" duration="1"/>
<testCase name="System Status Controller test getServerTime method with exception" duration="0"/>
<testCase name="System Status Controller test getResourceUsage method" duration="1"/>
<testCase name="System Status Controller test getResourceUsage method with exception" duration="0"/>
<testCase name="System Status Controller test getProcessInfo method" duration="1"/>
<testCase name="System Status Controller test getProcessInfo method with exception" duration="0"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/middleware/error-handler.spec.ts">
<testCase name="ErrorHandler middleware with 0 status code" duration="4"/>
<testCase name="ErrorHandler middleware with 200 status code" duration="0"/>
<testCase name="ErrorHandler middleware with 200 status code" duration="0"/>
<testCase name="ErrorHandler middleware with 200 status code and updated env variables" duration="1"/>
<testCase name="System Status Controller test getProcessInfo method" duration="0"/>
<testCase name="System Status Controller test getProcessInfo method with exception" duration="1"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/integration-tests/app.integration.spec.ts">
<testCase name="status integration tests can get default route success" duration="14"/>
<testCase name="status integration tests can get default web route success" duration="2"/>
<testCase name="status integration tests can get default route success" duration="16"/>
<testCase name="status integration tests can get default web route success" duration="3"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/integration-tests/status.integration.spec.ts">
<testCase name="status integration tests can get server time" duration="14"/>
<testCase name="status integration tests can get server system info" duration="5"/>
<testCase name="status integration tests can get server system usage" duration="2"/>
<testCase name="status integration tests can get server system process info" duration="2"/>
<testCase name="status integration tests should get the error" duration="3"/>
<testCase name="status integration tests can get server system info" duration="4"/>
<testCase name="status integration tests can get server system usage" duration="3"/>
<testCase name="status integration tests can get server system process info" duration="1"/>
<testCase name="status integration tests should get the error" duration="6"/>
</file>
<file path="/Users/santosh/Documents/workspace/personal/node-boilerplate/tests/unit-tests/middleware/error-handler.spec.ts">
<testCase name="ErrorHandler middleware with 0 status code" duration="3"/>
<testCase name="ErrorHandler middleware with 200 status code" duration="0"/>
<testCase name="ErrorHandler middleware with 200 status code" duration="1"/>
<testCase name="ErrorHandler middleware with 200 status code and updated env variables" duration="1"/>
</file>
</testExecutions>